fix(ui): bound dropdowns during scroll
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user