From 1cab9fdf6b4e140d83bc5d1d3e4e7422e282baca Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Wed, 21 Feb 2024 11:25:23 +0700 Subject: [PATCH] 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