File tree Expand file tree Collapse file tree 1 file changed +19
-3
lines changed
src/routes/products/search Expand file tree Collapse file tree 1 file changed +19
-3
lines changed Original file line number Diff line number Diff line change 1515 } = $props ();
1616
1717 let showAll: boolean = $state (false );
18+ let dropdownElement: HTMLDetailsElement ;
19+
1820 function toggleShowAll() {
1921 showAll = ! showAll ;
2022 }
2123
24+ function handleSelect(item : FacetItem ) {
25+ onSelect (item );
26+ if (dropdownElement ) {
27+ dropdownElement .open = false ;
28+ }
29+ }
30+
31+ function handleUnselect(item : FacetItem ) {
32+ onUnselect (item );
33+ if (dropdownElement ) {
34+ dropdownElement .open = false ;
35+ }
36+ }
37+
2238 let searchQuery: string = $state (' ' );
2339 let visibleValues = $derived .by (() => {
2440 if (searchQuery ) {
3551 });
3652 </script >
3753
38- <details class =" dropdown dropdown-center" >
54+ <details class ="dropdown dropdown-center" bind:this ={ dropdownElement } >
3955 <summary class =" btn flex w-58 items-center justify-start gap-2" >
4056 {facet .name } ({facet .items .length })
4157 <span class =" flex-grow" ></span >
6076 onchange ={(e ) => {
6177 const isSelected = e .currentTarget .checked ;
6278 if (isSelected ) {
63- onSelect (item );
79+ handleSelect (item );
6480 } else {
65- onUnselect (item );
81+ handleUnselect (item );
6682 }
6783 }}
6884 />
You can’t perform that action at this time.
0 commit comments