File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed
Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -73,15 +73,18 @@ const VirtualListOpen = forwardRef(
7373 menuEl : menuRefObject ?. current ,
7474 } ) ;
7575 } else {
76- scrollToIndex ( index ) ;
76+ // Fix for AWSUI-61506. Defer scroll to next frame to ensure
77+ // virtual items are measured after re-render. When called from
78+ // parent's useEffect, measurements may not be ready yet.
79+ requestAnimationFrame ( ( ) => scrollToIndex ( index ) ) ;
7780 }
7881 }
7982 previousHighlightedIndex . current = index ;
8083 } ,
8184 [ firstOptionSticky , highlightType . moveFocus , scrollToIndex ]
8285 ) ;
8386
84- const stickySize = firstOptionSticky ? virtualItems [ 0 ] . size : 0 ;
87+ const stickySize = firstOptionSticky ? ( virtualItems [ 0 ] ? .size ?? 0 ) : 0 ;
8588 const withScrollbar = ! ! width && width . inner < width . outer ;
8689
8790 const idPrefix = useUniqueId ( 'select-list-' ) ;
You can’t perform that action at this time.
0 commit comments