@@ -522,28 +522,32 @@ function SearchAutocompleteList(
522522 ) ;
523523
524524 return (
525- < SelectionList < OptionData | SearchQueryItem >
526- sections = { sections }
527- onSelectRow = { onListItemPress }
528- ListItem = { SearchRouterItem }
529- containerStyle = { [ styles . mh100 ] }
530- sectionListStyle = { [ styles . ph2 , styles . pb2 , styles . overscrollBehaviorContain ] }
531- listItemWrapperStyle = { [ styles . pr0 , styles . pl0 ] }
532- getItemHeight = { getItemHeight }
533- onLayout = { ( ) => {
534- setPerformanceTimersEnd ( ) ;
535- setIsInitialRender ( false ) ;
536- } }
537- showScrollIndicator = { ! shouldUseNarrowLayout }
538- sectionTitleStyles = { styles . mhn2 }
539- shouldSingleExecuteRowSelect
540- onArrowFocus = { onArrowFocus }
541- ref = { ref }
542- initiallyFocusedOptionKey = { ! shouldUseNarrowLayout ? styledRecentReports . at ( 0 ) ?. keyForList : undefined }
543- shouldScrollToFocusedIndex = { ! isInitialRender }
544- shouldSubscribeToArrowKeyEvents = { shouldSubscribeToArrowKeyEvents }
545- disableKeyboardShortcuts = { ! shouldSubscribeToArrowKeyEvents }
546- />
525+ // On page refresh, when the list is rendered before options are initialized the auto-focusing on initiallyFocusedOptionKey
526+ // will fail because the list will be empty on first render so we only render after options are initialized.
527+ areOptionsInitialized && (
528+ < SelectionList < OptionData | SearchQueryItem >
529+ sections = { sections }
530+ onSelectRow = { onListItemPress }
531+ ListItem = { SearchRouterItem }
532+ containerStyle = { [ styles . mh100 ] }
533+ sectionListStyle = { [ styles . ph2 , styles . pb2 , styles . overscrollBehaviorContain ] }
534+ listItemWrapperStyle = { [ styles . pr0 , styles . pl0 ] }
535+ getItemHeight = { getItemHeight }
536+ onLayout = { ( ) => {
537+ setPerformanceTimersEnd ( ) ;
538+ setIsInitialRender ( false ) ;
539+ } }
540+ showScrollIndicator = { ! shouldUseNarrowLayout }
541+ sectionTitleStyles = { styles . mhn2 }
542+ shouldSingleExecuteRowSelect
543+ onArrowFocus = { onArrowFocus }
544+ ref = { ref }
545+ initiallyFocusedOptionKey = { ! shouldUseNarrowLayout ? styledRecentReports . at ( 0 ) ?. keyForList : undefined }
546+ shouldScrollToFocusedIndex = { ! isInitialRender }
547+ shouldSubscribeToArrowKeyEvents = { shouldSubscribeToArrowKeyEvents }
548+ disableKeyboardShortcuts = { ! shouldSubscribeToArrowKeyEvents }
549+ />
550+ )
547551 ) ;
548552}
549553
0 commit comments