From 7cf7314e51cd3f5df5287418ba81e882a144fad6 Mon Sep 17 00:00:00 2001 From: Ana Margarida Silva Date: Mon, 25 Sep 2023 14:52:14 +0100 Subject: [PATCH] fix: show selected tag even if all are disabled, to allow to de-select it --- src/libs/OptionsListUtils.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/libs/OptionsListUtils.js b/src/libs/OptionsListUtils.js index 7c36fa095029..56411be6cc04 100644 --- a/src/libs/OptionsListUtils.js +++ b/src/libs/OptionsListUtils.js @@ -814,6 +814,24 @@ function getTagListSections(tags, recentlyUsedTags, selectedOptions, searchInput const numberOfTags = _.size(enabledTags); let indexOffset = 0; + // If all tags are disabled but there's a previously selected tag, show only the selected tag + if (numberOfTags === 0 && selectedOptions.length > 0) { + const selectedTagOptions = _.map(selectedOptions, (option) => ({ + name: option.name, + // Should be marked as enabled to be able to be de-selected + enabled: true, + })); + tagSections.push({ + // "Selected" section + title: '', + shouldShow: false, + indexOffset, + data: getTagsOptions(selectedTagOptions), + }); + + return tagSections; + } + if (!_.isEmpty(searchInputValue)) { const searchTags = _.filter(enabledTags, (tag) => tag.name.toLowerCase().includes(searchInputValue.toLowerCase()));