File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed
packages/@react-spectrum/combobox/src Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -108,7 +108,7 @@ const ComboBoxBase = React.forwardRef(function ComboBoxBase<T extends object>(pr
108
108
state
109
109
) ;
110
110
111
- let { overlayProps, placement} = useOverlayPosition ( {
111
+ let { overlayProps, placement, updatePosition } = useOverlayPosition ( {
112
112
targetRef : unwrappedButtonRef ,
113
113
overlayRef : unwrappedPopoverRef ,
114
114
scrollRef : listBoxRef ,
@@ -137,6 +137,17 @@ const ComboBoxBase = React.forwardRef(function ComboBoxBase<T extends object>(pr
137
137
138
138
useLayoutEffect ( onResize , [ scale , onResize ] ) ;
139
139
140
+ // Update position once the ListBox has rendered. This ensures that
141
+ // it flips properly when it doesn't fit in the available space.
142
+ // TODO: add ResizeObserver to useOverlayPosition so we don't need this.
143
+ useLayoutEffect ( ( ) => {
144
+ if ( state . isOpen ) {
145
+ requestAnimationFrame ( ( ) => {
146
+ updatePosition ( ) ;
147
+ } ) ;
148
+ }
149
+ } , [ state . isOpen , updatePosition ] ) ;
150
+
140
151
let style = {
141
152
...overlayProps . style ,
142
153
width : isQuiet ? null : menuWidth ,
You can’t perform that action at this time.
0 commit comments