Skip to content

Commit 20eb3ed

Browse files
committed
fix(web): clear composer drop highlight when a drag is cancelled
Signed-off-by: Yordis Prieto <[email protected]>
1 parent 7048e83 commit 20eb3ed

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

‎apps/web/src/components/chat/ChatComposer.tsx‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1929,6 +1929,20 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
19291929
if (nextTarget instanceof Node && event.currentTarget.contains(nextTarget)) return;
19301930
setIsDragOverComposer(false);
19311931
};
1932+
1933+
// A cancelled drag (Escape) can end without a dragleave on the hovered
1934+
// target, which would leave the drop highlight stuck. dragend always fires
1935+
// on the in-page drag source and bubbles to window, so it is the reset of
1936+
// last resort while the highlight is up.
1937+
useEffect(() => {
1938+
if (!isDragOverComposer) return;
1939+
const onWindowDragEnd = () => {
1940+
dragDepthRef.current = 0;
1941+
setIsDragOverComposer(false);
1942+
};
1943+
window.addEventListener("dragend", onWindowDragEnd);
1944+
return () => window.removeEventListener("dragend", onWindowDragEnd);
1945+
}, [isDragOverComposer]);
19321946
const handleInterruptPrimaryAction = useCallback(() => {
19331947
void onInterrupt();
19341948
}, [onInterrupt]);

0 commit comments

Comments
 (0)