Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/Search/SearchAutocompleteList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,7 @@ function SearchAutocompleteList(
// will fail because the list will be empty on first render so we only render after options are initialized.
areOptionsInitialized && (

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SearchAutocompleteList also be used in SearchPageHeaderInput and we haven't checked areOptionsInitialized in SearchPageHeaderInput

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DylanDylann I've inverted that line so we check for areOptionsInitialized again. As described in other comments the issue with brief noskeleton is caused by SelectionList itself.

I've raised a discussion on slack https://expensify.slack.com/archives/C049HHMV9SM/p1754305345538499

<SelectionList<OptionData | SearchQueryItem>
showLoadingPlaceholder={!areOptionsInitialized}
showLoadingPlaceholder
fixedNumItemsForLoader={4}
loaderSpeed={CONST.TIMING.SKELETON_ANIMATION_SPEED}
sections={sections}
Expand Down
99 changes: 54 additions & 45 deletions src/components/Search/SearchRouter/SearchRouter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import type {ValueOf} from 'type-fest';
import HeaderWithBackButton from '@components/HeaderWithBackButton';
import * as Expensicons from '@components/Icon/Expensicons';
import {usePersonalDetails} from '@components/OnyxListItemProvider';
import {useOptionsList} from '@components/OptionListContextProvider';
import OptionsListSkeletonView from '@components/OptionsListSkeletonView';
import type {AnimatedTextInputRef} from '@components/RNTextInput';
import type {GetAdditionalSectionsCallback} from '@components/Search/SearchAutocompleteList';
import SearchAutocompleteList from '@components/Search/SearchAutocompleteList';
Expand Down Expand Up @@ -83,7 +85,10 @@ function SearchRouter({onRouterClose, shouldHideInputCaret, isSearchRouterDispla
const {translate} = useLocalize();
const styles = useThemeStyles();
const [, recentSearchesMetadata] = useOnyx(ONYXKEYS.RECENT_SEARCHES, {canBeMissing: true});
const {areOptionsInitialized} = useOptionsList();
const [isSearchingForReports] = useOnyx(ONYXKEYS.IS_SEARCHING_FOR_REPORTS, {initWithStoredValues: false, canBeMissing: true});
const isRecentSearchesDataLoaded = !isLoadingOnyxValue(recentSearchesMetadata);
const shouldShowList = isRecentSearchesDataLoaded && areOptionsInitialized;
const personalDetails = usePersonalDetails();
const [reports] = useOnyx(ONYXKEYS.COLLECTION.REPORT, {canBeMissing: true});
const [workspaceCardFeeds] = useOnyx(ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST, {canBeMissing: true});
Expand Down Expand Up @@ -450,7 +455,6 @@ function SearchRouter({onRouterClose, shouldHideInputCaret, isSearchRouterDispla
});

const modalWidth = shouldUseNarrowLayout ? styles.w100 : {width: variables.searchRouterPopoverWidth};
const isRecentSearchesDataLoaded = !isLoadingOnyxValue(recentSearchesMetadata);

const focusTimeoutRef = useRef<NodeJS.Timeout | null>(null);
/** We added a delay to focus on text input to allow navigation/modal animations to get completed, see issue https://github.com/Expensify/App/issues/65855 for more details */
Expand Down Expand Up @@ -482,51 +486,56 @@ function SearchRouter({onRouterClose, shouldHideInputCaret, isSearchRouterDispla
shouldDisplayHelpButton={false}
/>
)}
{isRecentSearchesDataLoaded && (
<>
<SearchInputSelectionWrapper
value={textInputValue}
isFullWidth={shouldUseNarrowLayout}
onSearchQueryChange={onSearchQueryChange}
onSubmit={() => {
const focusedOption = listRef.current?.getFocusedOption();

if (!focusedOption) {
submitSearch(textInputValue);
return;
}
<SearchInputSelectionWrapper
value={textInputValue}
isFullWidth={shouldUseNarrowLayout}
onSearchQueryChange={onSearchQueryChange}
onSubmit={() => {
const focusedOption = listRef.current?.getFocusedOption();

if (!focusedOption) {
submitSearch(textInputValue);
return;
}

onListItemPress(focusedOption);
}}
caretHidden={shouldHideInputCaret}
autocompleteListRef={listRef}
shouldShowOfflineMessage
wrapperStyle={{...styles.border, ...styles.alignItemsCenter}}
outerWrapperStyle={[shouldUseNarrowLayout ? styles.mv3 : styles.mv2, shouldUseNarrowLayout ? styles.mh5 : styles.mh2]}
wrapperFocusedStyle={styles.borderColorFocus}
isSearchingForReports={isSearchingForReports}
selection={selection}
substitutionMap={autocompleteSubstitutions}
ref={textInputRef}
autoFocus={false}
/>
<SearchAutocompleteList
autocompleteQueryValue={autocompleteQueryValue || textInputValue}
handleSearch={searchInServer}
searchQueryItem={searchQueryItem}
getAdditionalSections={getAdditionalSections}
onListItemPress={onListItemPress}
setTextQuery={setTextAndUpdateSelection}
updateAutocompleteSubstitutions={updateAutocompleteSubstitutions}
onHighlightFirstItem={() => listRef.current?.updateAndScrollToFocusedIndex(1)}
ref={listRef}
textInputRef={textInputRef}
personalDetails={personalDetails}
reports={reports}
allFeeds={allFeeds}
allCards={allCards}
/>
</>
onListItemPress(focusedOption);
}}
caretHidden={shouldHideInputCaret}
autocompleteListRef={listRef}
shouldShowOfflineMessage
wrapperStyle={{...styles.border, ...styles.alignItemsCenter}}
outerWrapperStyle={[shouldUseNarrowLayout ? styles.mv3 : styles.mv2, shouldUseNarrowLayout ? styles.mh5 : styles.mh2]}
wrapperFocusedStyle={styles.borderColorFocus}
isSearchingForReports={isSearchingForReports}
selection={selection}
substitutionMap={autocompleteSubstitutions}
ref={textInputRef}
autoFocus={false}
/>
{shouldShowList && (
<SearchAutocompleteList
autocompleteQueryValue={autocompleteQueryValue || textInputValue}
handleSearch={searchInServer}
searchQueryItem={searchQueryItem}
getAdditionalSections={getAdditionalSections}
onListItemPress={onListItemPress}
setTextQuery={setTextAndUpdateSelection}
updateAutocompleteSubstitutions={updateAutocompleteSubstitutions}
onHighlightFirstItem={() => listRef.current?.updateAndScrollToFocusedIndex(1)}
ref={listRef}
textInputRef={textInputRef}
personalDetails={personalDetails}
reports={reports}
allFeeds={allFeeds}
allCards={allCards}
/>
)}
{!shouldShowList && (
<OptionsListSkeletonView
fixedNumItems={4}
shouldStyleAsTable
speed={CONST.TIMING.SKELETON_ANIMATION_SPEED}
/>
)}
</View>
);
Expand Down
Loading