Skip to content

Commit

Permalink
fix(selection-list): render pronouns after load
Browse files Browse the repository at this point in the history
  • Loading branch information
thiagobrez committed Aug 25, 2023
1 parent 19aaf95 commit 86ebe93
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions src/pages/settings/Profile/PronounsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,7 @@ function PronounsPage(props) {
* Pronouns list filtered by searchValue needed for the OptionsSelector.
* Empty array if the searchValue is empty.
*/
const filteredPronounsList = useMemo(() => {
const searchedValue = searchValue.trim();
if (searchedValue.length === 0) {
return [];
}
return _.filter(pronounsList, (pronous) => pronous.text.toLowerCase().indexOf(searchedValue.toLowerCase()) >= 0);
}, [pronounsList, searchValue]);
const filteredPronounsList = _.filter(pronounsList, (pronous) => pronous.text.toLowerCase().indexOf(searchValue.trim().toLowerCase()) >= 0);

const headerMessage = searchValue.trim() && !filteredPronounsList.length ? props.translate('common.noResultsFound') : '';

Expand All @@ -104,7 +98,8 @@ function PronounsPage(props) {
onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS_PROFILE)}
/>
<Text style={[styles.ph5, styles.mb3]}>{props.translate('pronounsPage.isShownOnProfile')}</Text>
{filteredPronounsList.length > 0 && (
{/* Only render pronouns if list was loaded (not filtered list), otherwise initially focused item will be empty */}
{pronounsList.length > 0 && (
<SelectionList
headerMessage={headerMessage}
textInputLabel={props.translate('pronounsPage.pronouns')}
Expand Down

0 comments on commit 86ebe93

Please sign in to comment.