Skip to content

Commit 7e0db85

Browse files
committed
fix(Select): update popover position
1 parent 0c70f78 commit 7e0db85

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/components/fields/Select/Select.tsx

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ import {
4747
forwardRefWithGenerics,
4848
mergeProps,
4949
useCombinedRefs,
50+
useLayoutEffect,
5051
} from '../../../utils/react/index';
5152
import { useFocus } from '../../../utils/react/interactions';
5253
import { useEventBus } from '../../../utils/react/useEventBus';
@@ -322,7 +323,7 @@ function Select<T extends object>(
322323
triggerRef,
323324
);
324325

325-
let { overlayProps, placement } = useOverlayPosition({
326+
let { overlayProps, placement, updatePosition } = useOverlayPosition({
326327
targetRef: triggerRef,
327328
overlayRef: popoverRef,
328329
scrollRef: listBoxRef,
@@ -467,6 +468,7 @@ function Select<T extends object>(
467468
listBoxRef={listBoxRef}
468469
overlayProps={overlayProps}
469470
placement={placement}
471+
updatePosition={updatePosition}
470472
state={state}
471473
listBoxStyles={listBoxStyles}
472474
overlayStyles={overlayStyles}
@@ -501,6 +503,7 @@ export function ListBoxPopup({
501503
overlayProps: parentOverlayProps,
502504
shouldUseVirtualFocus = false,
503505
placement,
506+
updatePosition,
504507
minWidth,
505508
size = 'small',
506509
triggerRef,
@@ -510,6 +513,19 @@ export function ListBoxPopup({
510513
// For trigger+popover components, map 'small' size to 'medium' for list items
511514
// while preserving 'medium' and 'large' sizes
512515
const listItemSize = size === 'small' ? 'medium' : size;
516+
517+
// Update position when overlay opens
518+
useLayoutEffect(() => {
519+
if (state.isOpen) {
520+
// Use double RAF to ensure layout is complete before positioning
521+
requestAnimationFrame(() => {
522+
requestAnimationFrame(() => {
523+
updatePosition?.();
524+
});
525+
});
526+
}
527+
}, [state.isOpen, updatePosition]);
528+
513529
// Get props for the listbox
514530
let { listBoxProps } = useListBox(
515531
{

0 commit comments

Comments
 (0)