File tree Expand file tree Collapse file tree 2 files changed +7
-23
lines changed
src/components/tag-filter Expand file tree Collapse file tree 2 files changed +7
-23
lines changed Original file line number Diff line number Diff line change @@ -88,17 +88,6 @@ describe(TagFilter.name, () => {
8888 expect ( mockOnChangeValues ) . toHaveBeenCalledWith ( [ ] ) ;
8989 } ) ;
9090
91- it ( 'automatically toggles to "show all" (empty array) when the last tag is clicked and all tags become selected' , async ( ) => {
92- const { user, mockOnChangeValues } = setup ( {
93- values : [ 'opt1' , 'opt2' ] ,
94- } ) ;
95-
96- // Click the last tag to select all tags - should auto-toggle to empty array
97- await user . click ( screen . getByText ( 'Option 3' ) ) ;
98-
99- expect ( mockOnChangeValues ) . toHaveBeenCalledWith ( [ ] ) ;
100- } ) ;
101-
10291 it ( 'does not render "Show all" tag when hideShowAll is true' , ( ) => {
10392 setup ( {
10493 hideShowAll : true ,
Original file line number Diff line number Diff line change @@ -24,18 +24,13 @@ export default function TagFilter<T extends string>({
2424 const isShowAll = useMemo ( ( ) => values . length === 0 , [ values ] ) ;
2525
2626 const onChangeSingleValue = useCallback (
27- ( value : T ) => {
28- const newValues = values . includes ( value )
29- ? values . filter ( ( v ) => v !== value )
30- : [ ...values , value ] ;
31-
32- // If all tags are selected, automatically toggle to "show all" (empty array)
33- const areAllTagsSelected = tagKeys . every ( ( key ) =>
34- newValues . includes ( key )
35- ) ;
36- onChangeValues ( areAllTagsSelected ? [ ] : newValues ) ;
37- } ,
38- [ values , onChangeValues , tagKeys ]
27+ ( value : T ) =>
28+ onChangeValues (
29+ values . includes ( value )
30+ ? values . filter ( ( v ) => v !== value )
31+ : [ ...values , value ]
32+ ) ,
33+ [ values , onChangeValues ]
3934 ) ;
4035
4136 return (
You can’t perform that action at this time.
0 commit comments