Skip to content

Commit d57b5df

Browse files
authored
[Security Solution][Detection Rules] Fixes rules table tag display bug (#85229) (#85354)
1 parent 0ee9255 commit d57b5df

File tree

5 files changed

+13
-1
lines changed

5 files changed

+13
-1
lines changed

x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/all/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,7 @@ export const AllRules = React.memo<AllRulesProps>(
503503
onFilterChanged={onFilterChangedCallback}
504504
rulesCustomInstalled={rulesCustomInstalled}
505505
rulesInstalled={rulesInstalled}
506+
currentFilterTags={filterOptions.tags ?? []}
506507
/>
507508
</HeaderSection>
508509

x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/all/rules_table_filters/rules_table_filters.test.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ describe('RulesTableFilters', () => {
1818
onFilterChanged={jest.fn()}
1919
rulesCustomInstalled={null}
2020
rulesInstalled={null}
21+
currentFilterTags={[]}
2122
/>
2223
);
2324

@@ -37,6 +38,7 @@ describe('RulesTableFilters', () => {
3738
onFilterChanged={jest.fn()}
3839
rulesCustomInstalled={10}
3940
rulesInstalled={9}
41+
currentFilterTags={[]}
4042
/>
4143
);
4244

x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/all/rules_table_filters/rules_table_filters.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ interface RulesTableFiltersProps {
2525
onFilterChanged: (filterOptions: Partial<FilterOptions>) => void;
2626
rulesCustomInstalled: number | null;
2727
rulesInstalled: number | null;
28+
currentFilterTags: string[];
2829
}
2930

3031
/**
@@ -37,6 +38,7 @@ const RulesTableFiltersComponent = ({
3738
onFilterChanged,
3839
rulesCustomInstalled,
3940
rulesInstalled,
41+
currentFilterTags,
4042
}: RulesTableFiltersProps) => {
4143
const [filter, setFilter] = useState<string>('');
4244
const [selectedTags, setSelectedTags] = useState<string[]>([]);
@@ -94,6 +96,7 @@ const RulesTableFiltersComponent = ({
9496
onSelectedTagsChanged={handleSelectedTags}
9597
selectedTags={selectedTags}
9698
tags={tags}
99+
currentFilterTags={currentFilterTags}
97100
data-test-subj="allRulesTagPopover"
98101
/>
99102
</EuiFilterGroup>

x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/all/rules_table_filters/tags_filter_popover.test.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ describe('TagsFilterPopover', () => {
1616
tags={[]}
1717
selectedTags={[]}
1818
onSelectedTagsChanged={jest.fn()}
19+
currentFilterTags={[]}
1920
isLoading={false}
2021
/>
2122
);

x-pack/plugins/security_solution/public/detections/pages/detection_engine/rules/all/rules_table_filters/tags_filter_popover.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ interface TagsFilterPopoverProps {
3333
selectedTags: string[];
3434
tags: string[];
3535
onSelectedTagsChanged: Dispatch<SetStateAction<string[]>>;
36+
currentFilterTags: string[];
3637
// eslint-disable-next-line react/no-unused-prop-types
3738
isLoading: boolean; // TO DO reimplement?
3839
}
@@ -62,8 +63,12 @@ const TagsFilterPopoverComponent = ({
6263
tags,
6364
selectedTags,
6465
onSelectedTagsChanged,
66+
currentFilterTags,
6567
}: TagsFilterPopoverProps) => {
66-
const sortedTags = useMemo(() => caseInsensitiveSort(tags), [tags]);
68+
const sortedTags = useMemo(
69+
() => caseInsensitiveSort(Array.from(new Set([...tags, ...currentFilterTags]))),
70+
[tags, currentFilterTags]
71+
);
6772
const [isTagPopoverOpen, setIsTagPopoverOpen] = useState(false);
6873
const [searchInput, setSearchInput] = useState('');
6974
const [filterTags, setFilterTags] = useState(sortedTags);

0 commit comments

Comments
 (0)