Skip to content

Commit

Permalink
refactor: don't show hover overlay during item drop
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisvxd committed Nov 22, 2024
1 parent c85d24e commit 858bfe7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 13 deletions.
12 changes: 9 additions & 3 deletions packages/core/components/DragDropContext/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,13 @@ export const DragDropContext = ({ children }: { children: ReactNode }) => {
<DragDropProvider
manager={manager}
onDragEnd={(event) => {
setDraggedItem(null);

const { source, target } = event.operation;

if (!source) return;
if (!source) {
setDraggedItem(null);

return;
}

const { zone, index } = source.data as ComponentDndData;

Expand Down Expand Up @@ -244,6 +246,10 @@ export const DragDropContext = ({ children }: { children: ReactNode }) => {
dragListeners.dragend?.forEach((fn) => {
fn(event, manager);
});

setTimeout(() => {
setDraggedItem(null);
}, 10);
}, 250);
}}
onDragOver={(event, manager) => {
Expand Down
23 changes: 13 additions & 10 deletions packages/core/components/DraggableComponent/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -365,17 +365,20 @@ export const DraggableComponent = ({
setDragAxis(autoDragAxis);
}, [ref, userDragAxis, autoDragAxis]);

useEffect(sync, [
ref,
overlayRef,
isVisible,
userIsDragging,
hover,
iframe,
state.data,
]);
useEffect(sync, [ref, overlayRef, isVisible, hover, iframe, state.data]);

const [ready, setReady] = useState(false);

useEffect(() => {
if (!userIsDragging) {
sync();
setReady(true);
} else {
setReady(false);
}
}, [userIsDragging]);

const overlayReady = ref.current && overlayRef.current;
const overlayReady = ref.current && overlayRef.current && ready;

return (
<DropZoneProvider
Expand Down

0 comments on commit 858bfe7

Please sign in to comment.