@@ -541,31 +541,35 @@ function SearchAutocompleteList(
541541 } , [ autocompleteQueryValue , onHighlightFirstItem , normalizedReferenceText ] ) ;
542542
543543 return (
544- < SelectionList < OptionData | SearchQueryItem >
545- showLoadingPlaceholder = { ! areOptionsInitialized }
546- fixedNumItemsForLoader = { 4 }
547- loaderSpeed = { CONST . TIMING . SKELETON_ANIMATION_SPEED }
548- sections = { sections }
549- onSelectRow = { onListItemPress }
550- ListItem = { SearchRouterItem }
551- containerStyle = { [ styles . mh100 ] }
552- sectionListStyle = { [ styles . ph2 , styles . pb2 , styles . overscrollBehaviorContain ] }
553- listItemWrapperStyle = { [ styles . pr0 , styles . pl0 ] }
554- getItemHeight = { getItemHeight }
555- onLayout = { ( ) => {
556- setPerformanceTimersEnd ( ) ;
557- setIsInitialRender ( false ) ;
558- } }
559- showScrollIndicator = { ! shouldUseNarrowLayout }
560- sectionTitleStyles = { styles . mhn2 }
561- shouldSingleExecuteRowSelect
562- onArrowFocus = { onArrowFocus }
563- ref = { ref }
564- initiallyFocusedOptionKey = { ! shouldUseNarrowLayout ? styledRecentReports . at ( 0 ) ?. keyForList : undefined }
565- shouldScrollToFocusedIndex = { ! isInitialRender }
566- shouldSubscribeToArrowKeyEvents = { shouldSubscribeToArrowKeyEvents }
567- disableKeyboardShortcuts = { ! shouldSubscribeToArrowKeyEvents }
568- />
544+ // On page refresh, when the list is rendered before options are initialized the auto-focusing on initiallyFocusedOptionKey
545+ // will fail because the list will be empty on first render so we only render after options are initialized.
546+ areOptionsInitialized && (
547+ < SelectionList < OptionData | SearchQueryItem >
548+ showLoadingPlaceholder = { ! areOptionsInitialized }
549+ fixedNumItemsForLoader = { 4 }
550+ loaderSpeed = { CONST . TIMING . SKELETON_ANIMATION_SPEED }
551+ sections = { sections }
552+ onSelectRow = { onListItemPress }
553+ ListItem = { SearchRouterItem }
554+ containerStyle = { [ styles . mh100 ] }
555+ sectionListStyle = { [ styles . ph2 , styles . pb2 , styles . overscrollBehaviorContain ] }
556+ listItemWrapperStyle = { [ styles . pr0 , styles . pl0 ] }
557+ getItemHeight = { getItemHeight }
558+ onLayout = { ( ) => {
559+ setPerformanceTimersEnd ( ) ;
560+ setIsInitialRender ( false ) ;
561+ } }
562+ showScrollIndicator = { ! shouldUseNarrowLayout }
563+ sectionTitleStyles = { styles . mhn2 }
564+ shouldSingleExecuteRowSelect
565+ onArrowFocus = { onArrowFocus }
566+ ref = { ref }
567+ initiallyFocusedOptionKey = { ! shouldUseNarrowLayout ? styledRecentReports . at ( 0 ) ?. keyForList : undefined }
568+ shouldScrollToFocusedIndex = { ! isInitialRender }
569+ shouldSubscribeToArrowKeyEvents = { shouldSubscribeToArrowKeyEvents }
570+ disableKeyboardShortcuts = { ! shouldSubscribeToArrowKeyEvents }
571+ />
572+ )
569573 ) ;
570574}
571575
0 commit comments