From 1cab9fdf6b4e140d83bc5d1d3e4e7422e282baca Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Wed, 21 Feb 2024 11:25:23 +0700 Subject: [PATCH 1/3] fix: disabled tag is not displayed in the list as selected --- src/libs/OptionsListUtils.ts | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index 80081061f340..f0e89f8e8d72 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -1061,7 +1061,7 @@ function getTagsOptions(tags: Category[]): Option[] { function getTagListSections(tags: Tag[], recentlyUsedTags: string[], selectedOptions: Category[], searchInputValue: string, maxRecentReportsToShow: number) { const tagSections = []; const sortedTags = sortTags(tags); - const enabledTags = sortedTags.filter((tag) => tag.enabled); + const enabledTags = [...selectedOptions, ...sortedTags.filter((tag) => tag.enabled)]; const numberOfTags = enabledTags.length; let indexOffset = 0; @@ -1119,13 +1119,10 @@ function getTagListSections(tags: Tag[], recentlyUsedTags: string[], selectedOpt const filteredTags = enabledTags.filter((tag) => !selectedOptionNames.includes(tag.name)); if (selectedOptions.length) { - const selectedTagOptions = selectedOptions.map((option) => { - const tagObject = tags.find((tag) => tag.name === option.name); - return { - name: option.name, - enabled: !!tagObject?.enabled, - }; - }); + const selectedTagOptions = selectedOptions.map((option) => ({ + name: option.name, + enabled: true, + })); tagSections.push({ // "Selected" section From cb3206f58f54783a6661af5a0844d882399a87a5 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Wed, 21 Feb 2024 12:00:41 +0700 Subject: [PATCH 2/3] filter enabled tag --- src/libs/OptionsListUtils.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index f0e89f8e8d72..eafda5ee1ce7 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -1061,7 +1061,8 @@ function getTagsOptions(tags: Category[]): Option[] { function getTagListSections(tags: Tag[], recentlyUsedTags: string[], selectedOptions: Category[], searchInputValue: string, maxRecentReportsToShow: number) { const tagSections = []; const sortedTags = sortTags(tags); - const enabledTags = [...selectedOptions, ...sortedTags.filter((tag) => tag.enabled)]; + const selectedOptionNames = selectedOptions.map((selectedOption) => selectedOption.name); + const enabledTags = [...selectedOptions, ...sortedTags.filter((tag) => tag.enabled && !selectedOptionNames.includes(tag.name))]; const numberOfTags = enabledTags.length; let indexOffset = 0; @@ -1109,7 +1110,6 @@ function getTagListSections(tags: Tag[], recentlyUsedTags: string[], selectedOpt return tagSections; } - const selectedOptionNames = selectedOptions.map((selectedOption) => selectedOption.name); const filteredRecentlyUsedTags = recentlyUsedTags .filter((recentlyUsedTag) => { const tagObject = tags.find((tag) => tag.name === recentlyUsedTag); From 325419b52aadfe65fe6f6ce7db1f8fedee6e267b Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Fri, 23 Feb 2024 23:44:09 +0700 Subject: [PATCH 3/3] Add comment --- src/libs/OptionsListUtils.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index eafda5ee1ce7..6f2a46de4f65 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -1121,6 +1121,7 @@ function getTagListSections(tags: Tag[], recentlyUsedTags: string[], selectedOpt if (selectedOptions.length) { const selectedTagOptions = selectedOptions.map((option) => ({ name: option.name, + // Should be marked as enabled to be able to unselect even though the selected category is disabled enabled: true, }));