Skip to content
Merged
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
32 changes: 19 additions & 13 deletions src/pages/settings/Profile/PersonalDetails/StateSelectionPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import React, {useCallback, useMemo, useState} from 'react';
import {View} from 'react-native';
import HeaderWithBackButton from '@components/HeaderWithBackButton';
import ScreenWrapper from '@components/ScreenWrapper';
import SelectionList from '@components/SelectionListWithSections';
import RadioListItem from '@components/SelectionListWithSections/RadioListItem';
import SelectionList from '@components/SelectionList';
import RadioListItem from '@components/SelectionList/ListItem/RadioListItem';
import useLocalize from '@hooks/useLocalize';
import Navigation from '@libs/Navigation/Navigation';
import searchOptions from '@libs/searchOptions';
Expand Down Expand Up @@ -66,6 +66,18 @@ function StateSelectionPage() {
[params?.backTo],
);

const textInputOptions = useMemo(
() => ({
headerMessage,
// Label can be an empty string
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
label: label || translate('common.state'),
value: searchValue,
onChangeText: setSearchValue,
}),
[headerMessage, label, searchValue, translate],
);

return (
<ScreenWrapper
testID={StateSelectionPage.displayName}
Expand All @@ -89,20 +101,14 @@ function StateSelectionPage() {
/>
{/* This empty, non-harmful view fixes the issue with SelectionList scrolling and shouldUseDynamicMaxToRenderPerBatch. It can be removed without consequences if a solution for SelectionList is found. See comment https://github.com/Expensify/App/pull/36770#issuecomment-2017028096 */}
<View />

<SelectionList
data={searchResults}
ListItem={RadioListItem}
onSelectRow={selectCountryState}
textInputOptions={textInputOptions}
initiallyFocusedItemKey={currentState}
shouldSingleExecuteRowSelect
headerMessage={headerMessage}
// Label can be an empty string
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
textInputLabel={label || translate('common.state')}
textInputValue={searchValue}
sections={[{data: searchResults}]}
onChangeText={setSearchValue}
initiallyFocusedOptionKey={currentState}
shouldUseDynamicMaxToRenderPerBatch
ListItem={RadioListItem}
disableMaintainingScrollPosition
addBottomSafeAreaPadding
/>
</ScreenWrapper>
Expand Down