fix(ui): bound dropdowns during scroll

This commit is contained in:
Codex
2026-07-27 14:36:35 +03:00
parent a8c8bfd89a
commit c5a6a58948
8 changed files with 100 additions and 14 deletions
+11 -1
View File
@@ -67,6 +67,16 @@ export function Dropdown({
const anchorNode = anchorElement ?? triggerElement;
if (!anchorNode || !surfaceRef.current) return;
const anchor = anchorNode.getBoundingClientRect();
const anchorVisible = (
anchor.bottom > 0
&& anchor.top < window.innerHeight
&& anchor.right > 0
&& anchor.left < window.innerWidth
);
if (!anchorVisible) {
close();
return;
}
const measured = surfaceRef.current.getBoundingClientRect();
const surfaceWidth = typeof width === "number"
? width
@@ -86,7 +96,7 @@ export function Dropdown({
maxHeight: position.maxHeight,
visibility: "visible",
});
}, [anchorElement, minWidth, offset, placement, triggerElement, width]);
}, [anchorElement, close, minWidth, offset, placement, triggerElement, width]);
useLayoutEffect(() => {
if (!isOpen) return;