-
Notifications
You must be signed in to change notification settings - Fork 3.9k
[CP Staging] Fix text input label in SelectionScreen
#79484
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| import React, {useCallback, useMemo, useState} from 'react'; | ||
| import React, {useMemo, useState} from 'react'; | ||
| import {View} from 'react-native'; | ||
| import BlockingView from '@components/BlockingViews/BlockingView'; | ||
| import RenderHTML from '@components/RenderHTML'; | ||
|
|
@@ -60,33 +60,27 @@ function WorkspaceCompanyCardAccountSelectCardPage({route}: WorkspaceCompanyCard | |
| return tokenizedSearch(exportMenuItem?.data ?? [], searchText, (option) => [option.value]); | ||
| }, [exportMenuItem?.data, searchText]); | ||
|
|
||
| const listEmptyContent = useMemo( | ||
| () => ( | ||
| <BlockingView | ||
| icon={illustrations.Telescope} | ||
| iconWidth={variables.emptyListIconWidth} | ||
| iconHeight={variables.emptyListIconHeight} | ||
| title={translate('workspace.moreFeatures.companyCards.noAccountsFound')} | ||
| subtitle={currentConnectionName ? translate('workspace.moreFeatures.companyCards.noAccountsFoundDescription', currentConnectionName) : undefined} | ||
| containerStyle={styles.pb10} | ||
| /> | ||
| ), | ||
| [translate, currentConnectionName, styles, illustrations.Telescope], | ||
| const listEmptyContent = ( | ||
| <BlockingView | ||
| icon={illustrations.Telescope} | ||
| iconWidth={variables.emptyListIconWidth} | ||
| iconHeight={variables.emptyListIconHeight} | ||
| title={translate('workspace.moreFeatures.companyCards.noAccountsFound')} | ||
| subtitle={currentConnectionName ? translate('workspace.moreFeatures.companyCards.noAccountsFoundDescription', currentConnectionName) : undefined} | ||
| containerStyle={styles.pb10} | ||
| /> | ||
| ); | ||
|
|
||
| const updateExportAccount = useCallback( | ||
| ({value}: SelectorType) => { | ||
| if (!exportMenuItem?.exportType) { | ||
| return; | ||
| } | ||
| const isDefaultSelected = value === defaultCard || value === defaultVendor; | ||
| const exportValue = isDefaultSelected ? CONST.COMPANY_CARDS.DEFAULT_EXPORT_TYPE : value; | ||
| setCompanyCardExportAccount(policyID, domainOrWorkspaceAccountID, cardID, exportMenuItem.exportType, exportValue, getCompanyCardFeed(feed)); | ||
| const updateExportAccount = ({value}: SelectorType) => { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❌ PERF-4 (docs)The Suggested fix: Revert this change and keep the const updateExportAccount = useCallback(
({value}: SelectorType) => {
if (\!exportMenuItem?.exportType) {
return;
}
const isDefaultSelected = value === defaultCard || value === defaultVendor;
const exportValue = isDefaultSelected ? CONST.COMPANY_CARDS.DEFAULT_EXPORT_TYPE : value;
setCompanyCardExportAccount(policyID, domainOrWorkspaceAccountID, cardID, exportMenuItem.exportType, exportValue, getCompanyCardFeed(feed));
Navigation.goBack(ROUTES.WORKSPACE_COMPANY_CARD_DETAILS.getRoute(policyID, feed, cardID, backTo));
},
[exportMenuItem?.exportType, domainOrWorkspaceAccountID, cardID, policyID, feed, defaultCard, defaultVendor, backTo],
); |
||
| if (!exportMenuItem?.exportType) { | ||
| return; | ||
| } | ||
| const isDefaultSelected = value === defaultCard || value === defaultVendor; | ||
| const exportValue = isDefaultSelected ? CONST.COMPANY_CARDS.DEFAULT_EXPORT_TYPE : value; | ||
| setCompanyCardExportAccount(policyID, domainOrWorkspaceAccountID, cardID, exportMenuItem.exportType, exportValue, getCompanyCardFeed(feed)); | ||
|
|
||
| Navigation.goBack(ROUTES.WORKSPACE_COMPANY_CARD_DETAILS.getRoute(policyID, feed, cardID, backTo)); | ||
| }, | ||
| [exportMenuItem?.exportType, domainOrWorkspaceAccountID, cardID, policyID, feed, defaultCard, defaultVendor, backTo], | ||
| ); | ||
| Navigation.goBack(ROUTES.WORKSPACE_COMPANY_CARD_DETAILS.getRoute(policyID, feed, cardID, backTo)); | ||
| }; | ||
|
|
||
| return ( | ||
| <SelectionScreen | ||
|
|
@@ -113,9 +107,11 @@ function WorkspaceCompanyCardAccountSelectCardPage({route}: WorkspaceCompanyCard | |
| displayName="WorkspaceCompanyCardAccountSelectCardPage" | ||
| data={searchedListOptions ?? []} | ||
| listItem={RadioListItem} | ||
| textInputLabel={translate('common.search')} | ||
| textInputValue={searchText} | ||
| onChangeText={setSearchText} | ||
| textInputOptions={{ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❌ PERF-4 (docs)The Suggested fix: const textInputOptions = useMemo(
() => ({
label: translate('common.search'),
value: searchText,
onChangeText: setSearchText,
}),
[translate, searchText],
); |
||
| label: translate('common.search'), | ||
| value: searchText, | ||
| onChangeText: setSearchText, | ||
| }} | ||
| onSelectRow={updateExportAccount} | ||
| initiallyFocusedOptionKey={exportMenuItem?.data?.find((mode) => mode.isSelected)?.keyForList} | ||
| onBackButtonPress={() => Navigation.goBack(ROUTES.WORKSPACE_COMPANY_CARD_DETAILS.getRoute(policyID, feed, cardID, backTo))} | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❌ PERF-4 (docs)
The
listEmptyContentJSX element should remain memoized withuseMemo. SinceWorkspaceCompanyCardAccountSelectCardPageis not optimized by React Compiler andSelectionScreenis optimized, creating a new JSX element reference on every render prevents React from skipping re-renders ofSelectionScreen.Suggested fix:
Revert this change and keep the
useMemowrapper: