From 2e450c48fbe376c3158da2dffca5d0f0fa06068c Mon Sep 17 00:00:00 2001 From: DylanDylann Date: Tue, 17 Oct 2023 15:54:45 +0700 Subject: [PATCH 1/4] fix:28078 Search message shows Invalid email when typing email address in search field --- src/components/CategoryPicker/index.js | 2 +- src/libs/OptionsListUtils.js | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/components/CategoryPicker/index.js b/src/components/CategoryPicker/index.js index 13abf057e4b1..e7f68e7011fc 100644 --- a/src/components/CategoryPicker/index.js +++ b/src/components/CategoryPicker/index.js @@ -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 ( diff --git a/src/libs/OptionsListUtils.js b/src/libs/OptionsListUtils.js index fb6c6e4f493e..bf2732988545 100644 --- a/src/libs/OptionsListUtils.js +++ b/src/libs/OptionsListUtils.js @@ -1525,6 +1525,19 @@ function getHeaderMessage(hasSelectableOptions, hasUserToInvite, searchValue, ma return ''; } +/** + * Helper method that check if any search results match, and show the not found message. + * + * @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 @@ -1545,6 +1558,7 @@ export { getShareDestinationOptions, getMemberInviteOptions, getHeaderMessage, + getHeaderMessageForNonUserList, getPersonalDetailsForAccountIDs, getIOUConfirmationOptionsFromPayeePersonalDetail, getIOUConfirmationOptionsFromParticipants, From 7783ff45deb64d2dfd18da24e766024d087f389e Mon Sep 17 00:00:00 2001 From: DylanDylann Date: Tue, 17 Oct 2023 17:29:01 +0700 Subject: [PATCH 2/4] Use getHeaderMessageForNonUserList for tag picker --- src/components/TagPicker/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/TagPicker/index.js b/src/components/TagPicker/index.js index 8e7cf11f7e5a..05eca664bd0f 100644 --- a/src/components/TagPicker/index.js +++ b/src/components/TagPicker/index.js @@ -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 ( Date: Wed, 18 Oct 2023 13:47:49 +0700 Subject: [PATCH 3/4] Update src/libs/OptionsListUtils.js Co-authored-by: Maria D'Costa --- src/libs/OptionsListUtils.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libs/OptionsListUtils.js b/src/libs/OptionsListUtils.js index bf2732988545..464c4560ea3b 100644 --- a/src/libs/OptionsListUtils.js +++ b/src/libs/OptionsListUtils.js @@ -1525,6 +1525,7 @@ function getHeaderMessage(hasSelectableOptions, hasUserToInvite, searchValue, ma return ''; } + /** * Helper method that check if any search results match, and show the not found message. * From acde086467e66e2426a6a6e17cf27a68a9a7465b Mon Sep 17 00:00:00 2001 From: DylanDylann <141406735+DylanDylann@users.noreply.github.com> Date: Wed, 18 Oct 2023 13:47:56 +0700 Subject: [PATCH 4/4] Update src/libs/OptionsListUtils.js Co-authored-by: Maria D'Costa --- src/libs/OptionsListUtils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/OptionsListUtils.js b/src/libs/OptionsListUtils.js index 464c4560ea3b..283cc8709e51 100644 --- a/src/libs/OptionsListUtils.js +++ b/src/libs/OptionsListUtils.js @@ -1527,7 +1527,7 @@ function getHeaderMessage(hasSelectableOptions, hasUserToInvite, searchValue, ma } /** - * Helper method that check if any search results match, and show the not found message. + * 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