Skip to content

Commit

Permalink
Fix handleDrop event handler regressions
Browse files Browse the repository at this point in the history
  • Loading branch information
gocemitevski committed Oct 13, 2023
1 parent 983b079 commit 4362298
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/components/CanvasBackground/CanvasBackground.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export const CanvasBackground: React.FunctionComponent<
fileImage: files[0],
});
if (dragAndDropContainer.current) {
dragAndDropContainer.current.classList.remove("border-success");
dragAndDropContainer.current.children[0].classList.remove("border-success");
}
},
[canvasBackgroundValues, setCanvasBackgroundValues]
Expand All @@ -70,14 +70,14 @@ export const CanvasBackground: React.FunctionComponent<
const handleDragOver = useCallback((e: React.DragEvent<HTMLDivElement>) => {
e.preventDefault();
if (dragAndDropContainer.current) {
dragAndDropContainer.current.classList.add("border-success");
dragAndDropContainer.current.children[0].classList.add("border-success");
}
}, []);

const handleDragLeave = useCallback((e: React.DragEvent<HTMLDivElement>) => {
e.preventDefault();
if (dragAndDropContainer.current) {
dragAndDropContainer.current.classList.remove("border-success");
dragAndDropContainer.current.children[0].classList.remove("border-success");
}
}, []);

Expand Down
8 changes: 4 additions & 4 deletions src/components/CanvasIcon/CanvasIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export const CanvasIcon: React.FunctionComponent<CanvasIconProps> = (props) => {
const files = Array.from(e.dataTransfer.files);
setCanvasIconValues({ ...canvasIconValues, fileImage: files[0] });
if (dragAndDropContainer.current) {
dragAndDropContainer.current.classList.remove("border-success");
dragAndDropContainer.current.children[0].classList.remove("border-success");
}
},
[canvasIconValues, setCanvasIconValues]
Expand All @@ -72,14 +72,14 @@ export const CanvasIcon: React.FunctionComponent<CanvasIconProps> = (props) => {
const handleDragOver = useCallback((e: React.DragEvent<HTMLDivElement>) => {
e.preventDefault();
if (dragAndDropContainer.current) {
dragAndDropContainer.current.classList.add("border-success");
dragAndDropContainer.current.children[0].classList.add("border-success");
}
}, []);

const handleDragLeave = useCallback((e: React.DragEvent<HTMLDivElement>) => {
e.preventDefault();
if (dragAndDropContainer.current) {
dragAndDropContainer.current.classList.remove("border-success");
dragAndDropContainer.current.children[0].classList.remove("border-success");
}
}, []);

Expand Down Expand Up @@ -134,8 +134,8 @@ export const CanvasIcon: React.FunctionComponent<CanvasIconProps> = (props) => {
onDrop={handleDrop}
onDragOver={handleDragOver}
onDragLeave={handleDragLeave}
ref={dragAndDropContainer}
style={{ backgroundColor: canvasIconValues.color }}
ref={dragAndDropContainer}
>
{canvasIconValues.fileImageURL ? (
<div className="alert alert-dismissible">
Expand Down

0 comments on commit 4362298

Please sign in to comment.