Skip to content

Commit 004a16e

Browse files
committed
Show loading skeleton until SelectionList is fully rendered
1 parent 01dfa83 commit 004a16e

1 file changed

Lines changed: 38 additions & 28 deletions

File tree

src/components/Search/SearchAutocompleteList.tsx

Lines changed: 38 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {useOnyx} from 'react-native-onyx';
55
import * as Expensicons from '@components/Icon/Expensicons';
66
import {usePersonalDetails} from '@components/OnyxProvider';
77
import {useOptionsList} from '@components/OptionListContextProvider';
8+
import OptionsListSkeletonView from '@components/OptionsListSkeletonView';
89
import type {AnimatedTextInputRef} from '@components/RNTextInput';
910
import SelectionList from '@components/SelectionList';
1011
import type {SearchQueryItem, SearchQueryListItemProps} from '@components/SelectionList/Search/SearchQueryListItem';
@@ -604,34 +605,43 @@ function SearchAutocompleteList(
604605
}, [autocompleteQueryValue, onHighlightFirstItem, normalizedReferenceText]);
605606

606607
return (
607-
<SelectionList<OptionData | SearchQueryItem>
608-
showLoadingPlaceholder={!areOptionsInitialized}
609-
fixedNumItemsForLoader={4}
610-
loaderSpeed={CONST.TIMING.SKELETON_ANIMATION_SPEED}
611-
sections={sections}
612-
onSelectRow={onListItemPress}
613-
ListItem={SearchRouterItem}
614-
containerStyle={[styles.mh100]}
615-
sectionListStyle={[styles.ph2, styles.pb2, styles.overscrollBehaviorContain]}
616-
listItemWrapperStyle={[styles.pr0, styles.pl0]}
617-
getItemHeight={getItemHeight}
618-
onLayout={() => {
619-
setPerformanceTimersEnd();
620-
setIsInitialRender(false);
621-
if (!!textInputRef?.current && ref && 'current' in ref) {
622-
ref.current?.updateExternalTextInputFocus?.(textInputRef.current.isFocused());
623-
}
624-
}}
625-
showScrollIndicator={!shouldUseNarrowLayout}
626-
sectionTitleStyles={styles.mhn2}
627-
shouldSingleExecuteRowSelect
628-
onArrowFocus={onArrowFocus}
629-
ref={ref}
630-
initiallyFocusedOptionKey={!shouldUseNarrowLayout ? styledRecentReports.at(0)?.keyForList : undefined}
631-
shouldScrollToFocusedIndex={!isInitialRender}
632-
shouldSubscribeToArrowKeyEvents={shouldSubscribeToArrowKeyEvents}
633-
disableKeyboardShortcuts={!shouldSubscribeToArrowKeyEvents}
634-
/>
608+
<>
609+
{isInitialRender && (
610+
<OptionsListSkeletonView
611+
fixedNumItems={4}
612+
shouldStyleAsTable
613+
speed={CONST.TIMING.SKELETON_ANIMATION_SPEED}
614+
/>
615+
)}
616+
<SelectionList<OptionData | SearchQueryItem>
617+
showLoadingPlaceholder={!areOptionsInitialized}
618+
fixedNumItemsForLoader={4}
619+
loaderSpeed={CONST.TIMING.SKELETON_ANIMATION_SPEED}
620+
sections={sections}
621+
onSelectRow={onListItemPress}
622+
ListItem={SearchRouterItem}
623+
containerStyle={[styles.mh100]}
624+
sectionListStyle={[styles.ph2, styles.pb2, styles.overscrollBehaviorContain]}
625+
listItemWrapperStyle={[styles.pr0, styles.pl0]}
626+
getItemHeight={getItemHeight}
627+
onLayout={() => {
628+
setPerformanceTimersEnd();
629+
setIsInitialRender(false);
630+
if (!!textInputRef?.current && ref && 'current' in ref) {
631+
ref.current?.updateExternalTextInputFocus?.(textInputRef.current.isFocused());
632+
}
633+
}}
634+
showScrollIndicator={!shouldUseNarrowLayout}
635+
sectionTitleStyles={styles.mhn2}
636+
shouldSingleExecuteRowSelect
637+
onArrowFocus={onArrowFocus}
638+
ref={ref}
639+
initiallyFocusedOptionKey={!shouldUseNarrowLayout ? styledRecentReports.at(0)?.keyForList : undefined}
640+
shouldScrollToFocusedIndex={!isInitialRender}
641+
shouldSubscribeToArrowKeyEvents={shouldSubscribeToArrowKeyEvents}
642+
disableKeyboardShortcuts={!shouldSubscribeToArrowKeyEvents}
643+
/>
644+
</>
635645
);
636646
}
637647

0 commit comments

Comments
 (0)