Skip to content

Commit

Permalink
Merge pull request #36994 from dukenv0307/fix/35909
Browse files Browse the repository at this point in the history
  • Loading branch information
cead22 authored Feb 23, 2024
2 parents c71387c + 325419b commit acbfffe
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/libs/OptionsListUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = 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;

Expand Down Expand Up @@ -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);
Expand All @@ -1119,13 +1119,11 @@ 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,
// Should be marked as enabled to be able to unselect even though the selected category is disabled
enabled: true,
}));

tagSections.push({
// "Selected" section
Expand Down

0 comments on commit acbfffe

Please sign in to comment.