From 878f84e0fd0f42f0bf9aec3280829fa3ad65bad0 Mon Sep 17 00:00:00 2001 From: tienifr Date: Tue, 10 Oct 2023 01:06:09 +0700 Subject: [PATCH 1/2] Fix: 28988 parent for subcategories can be selected with arrow keys --- src/components/CategoryPicker/index.js | 3 ++- src/libs/actions/IOU.js | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/components/CategoryPicker/index.js b/src/components/CategoryPicker/index.js index ef8b1d71ad1d..13abf057e4b1 100644 --- a/src/components/CategoryPicker/index.js +++ b/src/components/CategoryPicker/index.js @@ -32,6 +32,7 @@ function CategoryPicker({selectedCategory, policyCategories, policyRecentlyUsedC }, [selectedCategory]); const sections = useMemo(() => { + const validPolicyRecentlyUsedCategories = _.filter(policyRecentlyUsedCategories, (p) => !_.isEmpty(p)); const {categoryOptions} = OptionsListUtils.getFilteredOptions( {}, {}, @@ -43,7 +44,7 @@ function CategoryPicker({selectedCategory, policyCategories, policyRecentlyUsedC false, true, policyCategories, - policyRecentlyUsedCategories, + validPolicyRecentlyUsedCategories, false, ); diff --git a/src/libs/actions/IOU.js b/src/libs/actions/IOU.js index 2c046bfc2a24..36277216f87c 100644 --- a/src/libs/actions/IOU.js +++ b/src/libs/actions/IOU.js @@ -482,7 +482,10 @@ function getMoneyRequestInformation( // For now it only uses the first tag of the policy, since multi-tags are not yet supported const tagListKey = _.first(_.keys(policyTags)); const uniquePolicyRecentlyUsedTags = recentlyUsedPolicyTags ? _.filter(recentlyUsedPolicyTags[tagListKey], (recentlyUsedPolicyTag) => recentlyUsedPolicyTag !== tag) : []; - optimisticPolicyRecentlyUsedTags[tagListKey] = [tag, ...uniquePolicyRecentlyUsedTags]; + if (tag) { + uniquePolicyRecentlyUsedTags.unshift(tag); + } + optimisticPolicyRecentlyUsedTags[tagListKey] = [...uniquePolicyRecentlyUsedTags]; } // If there is an existing transaction (which is the case for distance requests), then the data from the existing transaction From ba515e9230445104332f431382c9ccafb82e23e2 Mon Sep 17 00:00:00 2001 From: tienifr Date: Tue, 10 Oct 2023 09:43:12 +0700 Subject: [PATCH 2/2] fix: remove unnecessary code --- src/libs/actions/IOU.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/libs/actions/IOU.js b/src/libs/actions/IOU.js index 36277216f87c..2c046bfc2a24 100644 --- a/src/libs/actions/IOU.js +++ b/src/libs/actions/IOU.js @@ -482,10 +482,7 @@ function getMoneyRequestInformation( // For now it only uses the first tag of the policy, since multi-tags are not yet supported const tagListKey = _.first(_.keys(policyTags)); const uniquePolicyRecentlyUsedTags = recentlyUsedPolicyTags ? _.filter(recentlyUsedPolicyTags[tagListKey], (recentlyUsedPolicyTag) => recentlyUsedPolicyTag !== tag) : []; - if (tag) { - uniquePolicyRecentlyUsedTags.unshift(tag); - } - optimisticPolicyRecentlyUsedTags[tagListKey] = [...uniquePolicyRecentlyUsedTags]; + optimisticPolicyRecentlyUsedTags[tagListKey] = [tag, ...uniquePolicyRecentlyUsedTags]; } // If there is an existing transaction (which is the case for distance requests), then the data from the existing transaction