Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

20354 quick fix searchpage list refactor #35058

Merged
Show file tree
Hide file tree
Changes from 4 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: 2 additions & 0 deletions src/components/SelectionList/BaseSelectionList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ function BaseSelectionList<TItem extends User | RadioItem>(
shouldShowTooltips = true,
shouldUseDynamicMaxToRenderPerBatch = false,
rightHandSideComponent,
isLoadingNewOptions = false,
}: BaseSelectionListProps<TItem>,
inputRef: ForwardedRef<RNTextInput>,
) {
Expand Down Expand Up @@ -427,6 +428,7 @@ function BaseSelectionList<TItem extends User | RadioItem>(
spellCheck={false}
onSubmitEditing={selectFocusedOption}
blurOnSubmit={!!flattenedSections.allOptions.length}
isLoading={isLoadingNewOptions}
/>
</View>
)}
Expand Down
3 changes: 3 additions & 0 deletions src/components/SelectionList/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,9 @@ type BaseSelectionListProps<TItem extends User | RadioItem> = Partial<ChildrenPr

/** Component to display on the right side of each child */
rightHandSideComponent?: ((item: TItem) => ReactElement<TItem>) | ReactElement | null;

/** Whether to show the loading indicator for new options */
isLoadingNewOptions?: boolean;
};

type ItemLayout = {
Expand Down
223 changes: 0 additions & 223 deletions src/pages/SearchPage.js

This file was deleted.

2 changes: 1 addition & 1 deletion src/pages/SearchPage/SearchPageFooter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function SearchPageFooter() {
return (
<>
{shouldShowReferralCTA && (
<View style={[themeStyles.pb5, themeStyles.flexShrink0]}>
<View style={[themeStyles.flexShrink0]}>
<ReferralProgramCTA
referralContentType={CONST.REFERRAL_PROGRAM.CONTENT_TYPES.REFER_FRIEND}
onCloseButtonPress={() => setShouldShowReferralCTA(false)}
Expand Down
16 changes: 10 additions & 6 deletions src/pages/SearchPage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,15 @@ const propTypes = {

/** All reports shared with the user */
reports: PropTypes.objectOf(reportPropTypes),

/** Whether or not we are searching for reports on the server */
isSearchingForReports: PropTypes.bool,
};

const defaultProps = {
betas: [],
reports: {},
isSearchingForReports: false,
};

const setPerformanceTimersEnd = () => {
Expand All @@ -43,7 +47,7 @@ const setPerformanceTimersEnd = () => {

const SearchPageFooterInstance = <SearchPageFooter />;

function SearchPage({betas, reports}) {
function SearchPage({betas, reports, isSearchingForReports}) {
const [isScreenTransitionEnd, setIsScreenTransitionEnd] = useState(false);
const {translate} = useLocalize();
const {isOffline} = useNetwork();
Expand All @@ -59,10 +63,9 @@ function SearchPage({betas, reports}) {
Performance.markStart(CONST.TIMING.SEARCH_RENDER);
}, []);

const onChangeText = (text = '') => {
Report.searchInServer(text);
setSearchValue(text);
};
useEffect(() => {
Report.searchInServer(debouncedSearchValue.trim());
}, [debouncedSearchValue]);

const {
recentReports,
Expand Down Expand Up @@ -150,13 +153,14 @@ function SearchPage({betas, reports}) {
textInputValue={searchValue}
textInputLabel={translate('optionsSelector.nameEmailOrPhoneNumber')}
textInputHint={offlineMessage}
onChangeText={onChangeText}
onChangeText={setSearchValue}
headerMessage={headerMessage}
onLayout={setPerformanceTimersEnd}
autoFocus
onSelectRow={selectReport}
showLoadingPlaceholder={!didScreenTransitionEnd || !isOptionsDataReady}
footerContent={SearchPageFooterInstance}
isLoadingNewOptions={isSearchingForReports}
/>
</View>
</>
Expand Down
Loading