Skip to content

Commit

Permalink
Merge pull request #29741 from DylanDylann/fix/28078
Browse files Browse the repository at this point in the history
fix:28078 Search message shows Invalid email when typing email addres…
  • Loading branch information
MariaHCD committed Oct 18, 2023
2 parents 7b03a4d + acde086 commit 9664f8c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/components/CategoryPicker/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ function CategoryPicker({selectedCategory, policyCategories, policyRecentlyUsedC
return categoryInitialFocusedIndex;
}, [selectedCategory, searchValue, isCategoriesCountBelowThreshold, sections]);

const headerMessage = OptionsListUtils.getHeaderMessage(lodashGet(sections, '[0].data.length', 0) > 0, false, searchValue);
const headerMessage = OptionsListUtils.getHeaderMessageForNonUserList(lodashGet(sections, '[0].data.length', 0) > 0, searchValue);
const shouldShowTextInput = !isCategoriesCountBelowThreshold;

return (
Expand Down
2 changes: 1 addition & 1 deletion src/components/TagPicker/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function TagPicker({selectedTag, tag, policyTags, policyRecentlyUsedTags, onSubm
[searchValue, selectedOptions, policyTagList, policyRecentlyUsedTagsList],
);

const headerMessage = OptionsListUtils.getHeaderMessage(lodashGet(sections, '[0].data.length', 0) > 0, false, '');
const headerMessage = OptionsListUtils.getHeaderMessageForNonUserList(lodashGet(sections, '[0].data.length', 0) > 0, '');

return (
<OptionsSelector
Expand Down
15 changes: 15 additions & 0 deletions src/libs/OptionsListUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -1528,6 +1528,20 @@ function getHeaderMessage(hasSelectableOptions, hasUserToInvite, searchValue, ma
return '';
}

/**
* Helper method for non-user lists (eg. categories and tags) that returns the text to be used for the header's message and title (if any)
*
* @param {Boolean} hasSelectableOptions
* @param {String} searchValue
* @return {String}
*/
function getHeaderMessageForNonUserList(hasSelectableOptions, searchValue) {
if (searchValue && !hasSelectableOptions) {
return Localize.translate(preferredLocale, 'common.noResultsFound');
}
return '';
}

/**
* Helper method to check whether an option can show tooltip or not
* @param {Object} option
Expand All @@ -1547,6 +1561,7 @@ export {
getShareDestinationOptions,
getMemberInviteOptions,
getHeaderMessage,
getHeaderMessageForNonUserList,
getPersonalDetailsForAccountIDs,
getIOUConfirmationOptionsFromPayeePersonalDetail,
getIOUConfirmationOptionsFromParticipants,
Expand Down

0 comments on commit 9664f8c

Please sign in to comment.