Skip to content

Commit 7d4015c

Browse files
committed
update SelectionList conditional rendering
1 parent 2625609 commit 7d4015c

2 files changed

Lines changed: 30 additions & 32 deletions

File tree

src/components/Search/SearchAutocompleteList.tsx

Lines changed: 29 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -727,37 +727,35 @@ function SearchAutocompleteList(
727727
return (
728728
// On page refresh, when the list is rendered before options are initialized the auto-focusing on initiallyFocusedOptionKey
729729
// will fail because the list will be empty on first render so we only render after options are initialized.
730-
areOptionsInitialized && (
731-
<SelectionList<OptionData | SearchQueryItem>
732-
showLoadingPlaceholder={!areOptionsInitialized}
733-
fixedNumItemsForLoader={4}
734-
loaderSpeed={CONST.TIMING.SKELETON_ANIMATION_SPEED}
735-
sections={sections}
736-
onSelectRow={onListItemPress}
737-
ListItem={SearchRouterItem}
738-
containerStyle={[styles.mh100]}
739-
sectionListStyle={[styles.ph2, styles.pb2, styles.overscrollBehaviorContain]}
740-
listItemWrapperStyle={[styles.pr0, styles.pl0]}
741-
getItemHeight={getItemHeight}
742-
onLayout={() => {
743-
setPerformanceTimersEnd();
744-
setIsInitialRender(false);
745-
if (!!textInputRef?.current && ref && 'current' in ref) {
746-
ref.current?.updateExternalTextInputFocus?.(textInputRef.current.isFocused());
747-
}
748-
}}
749-
showScrollIndicator={!shouldUseNarrowLayout}
750-
sectionTitleStyles={styles.mhn2}
751-
shouldSingleExecuteRowSelect
752-
onArrowFocus={onArrowFocus}
753-
ref={ref}
754-
initiallyFocusedOptionKey={!shouldUseNarrowLayout ? styledRecentReports.at(0)?.keyForList : undefined}
755-
shouldScrollToFocusedIndex={!isInitialRender}
756-
shouldSubscribeToArrowKeyEvents={shouldSubscribeToArrowKeyEvents}
757-
disableKeyboardShortcuts={!shouldSubscribeToArrowKeyEvents}
758-
addBottomSafeAreaPadding
759-
/>
760-
)
730+
<SelectionList<OptionData | SearchQueryItem>
731+
showLoadingPlaceholder
732+
fixedNumItemsForLoader={4}
733+
loaderSpeed={CONST.TIMING.SKELETON_ANIMATION_SPEED}
734+
sections={sections}
735+
onSelectRow={onListItemPress}
736+
ListItem={SearchRouterItem}
737+
containerStyle={[styles.mh100]}
738+
sectionListStyle={[styles.ph2, styles.pb2, styles.overscrollBehaviorContain]}
739+
listItemWrapperStyle={[styles.pr0, styles.pl0]}
740+
getItemHeight={getItemHeight}
741+
onLayout={() => {
742+
setPerformanceTimersEnd();
743+
setIsInitialRender(false);
744+
if (!!textInputRef?.current && ref && 'current' in ref) {
745+
ref.current?.updateExternalTextInputFocus?.(textInputRef.current.isFocused());
746+
}
747+
}}
748+
showScrollIndicator={!shouldUseNarrowLayout}
749+
sectionTitleStyles={styles.mhn2}
750+
shouldSingleExecuteRowSelect
751+
onArrowFocus={onArrowFocus}
752+
ref={ref}
753+
initiallyFocusedOptionKey={!shouldUseNarrowLayout ? styledRecentReports.at(0)?.keyForList : undefined}
754+
shouldScrollToFocusedIndex={!isInitialRender}
755+
shouldSubscribeToArrowKeyEvents={shouldSubscribeToArrowKeyEvents}
756+
disableKeyboardShortcuts={!shouldSubscribeToArrowKeyEvents}
757+
addBottomSafeAreaPadding
758+
/>
761759
);
762760
}
763761

src/components/Search/SearchRouter/SearchRouter.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ import {InteractionManager, Keyboard, View} from 'react-native';
66
import type {ValueOf} from 'type-fest';
77
import HeaderWithBackButton from '@components/HeaderWithBackButton';
88
import * as Expensicons from '@components/Icon/Expensicons';
9+
import {usePersonalDetails} from '@components/OnyxProvider';
910
import {useOptionsList} from '@components/OptionListContextProvider';
1011
import OptionsListSkeletonView from '@components/OptionsListSkeletonView';
11-
import {usePersonalDetails} from '@components/OnyxProvider';
1212
import type {AnimatedTextInputRef} from '@components/RNTextInput';
1313
import type {GetAdditionalSectionsCallback} from '@components/Search/SearchAutocompleteList';
1414
import SearchAutocompleteList from '@components/Search/SearchAutocompleteList';

0 commit comments

Comments
 (0)