File tree Expand file tree Collapse file tree 5 files changed +14
-12
lines changed Expand file tree Collapse file tree 5 files changed +14
-12
lines changed Original file line number Diff line number Diff line change @@ -86,13 +86,12 @@ Comboboxes are the foundation of accessible autocompletes and command palettes f
8686 >
8787 {#each filtered as value}
8888 {@const active = $combobox.active === value}
89- {@const selected = $combobox.selected === value}
9089 <li
91- class="relative cursor-default select-none py-2 pl-10 pr-4 text-gray-900 focus:outline-none focus: bg-teal-600 focus: text-white group"
90+ class="relative cursor-default select-none py-2 pl-10 pr-4 focus:outline-none font-normal aria-selected:font-medium {active ? ' bg-teal-600 text-white' : 'text-gray-900'} group"
9291 use:combobox.item={{ value }}
9392 >
94- <span class="block truncate font-normal group-aria-selected:font-medium ">{value.name}</span>
95- <span class="absolute invisible group-aria-selected:visible inset-y-0 left-0 flex items-center pl-3 text-teal-600 group-focus: text-white ">
93+ <span class="block truncate">{value.name}</span>
94+ <span class="absolute invisible group-aria-selected:visible inset-y-0 left-0 flex items-center pl-3 {active ? ' text-white' : ' text-teal-600'} ">
9695 <Check class="h-5 w-5" />
9796 </span>
9897 </li>
Original file line number Diff line number Diff line change @@ -100,12 +100,13 @@ Pass an array to the `selected` property of `createCombobox` to trigger multi-se
100100 class="absolute mt-1 max-h-60 w-full overflow-auto rounded-md bg-white py-1 text-sm shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none"
101101 >
102102 {#each filtered as value}
103+ {@const active = $combobox.active === value}
103104 <li
104- class="relative cursor-default select-none py-2 pl-4 pr-9 focus:outline-none text-gray-900 focus: bg-teal-600 focus: text-white group"
105+ class="relative cursor-default select-none py-2 pl-4 pr-9 focus:outline-none font-normal aria-selected:font-medium {active ? ' bg-teal-600 text-white' : 'text-gray-900'} group"
105106 use:combobox.item={{ value }}
106107 >
107- <span class="block truncate font-normal group-focus:font-semibold ">{value.name}</span>
108- <span class="absolute invisible group-aria-selected:visible inset-y-0 right-0 flex items-center pr-3 text-teal-600 group-hover: text-white ">
108+ <span class="block truncate">{value.name}</span>
109+ <span class="absolute invisible group-aria-selected:visible inset-y-0 right-0 flex items-center pr-3 {active ? ' text-white' : ' text-teal-600'} ">
109110 <Check class="h-5 w-5" />
110111 </span>
111112 </li>
Original file line number Diff line number Diff line change @@ -74,7 +74,7 @@ export function createCombobox(init?: Partial<Combobox>) {
7474 set ( { expanded, opened, active } )
7575 const item = state . items [ active ]
7676 if ( item ) {
77- item . node . focus ( ) ;
77+ item . node . scrollIntoView ( { block : 'nearest' } )
7878 }
7979 }
8080 }
Original file line number Diff line number Diff line change 5454 class =" absolute mt-1 max-h-60 w-full overflow-auto rounded-md bg-white py-1 text-sm shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none"
5555 >
5656 {#each filtered as value }
57+ {@const active = $combobox .active === value }
5758 <li
58- class =" relative cursor-default select-none py-2 pl-10 pr-4 font-normal aria-selected:font-medium text-gray-900 focus:outline-none focus: bg-teal-600 focus: text-white group"
59+ class ="relative cursor-default select-none py-2 pl-10 pr-4 focus:outline-none font-normal aria-selected:font-medium { active ? ' bg-teal-600 text-white' : ' text-gray-900 ' } group"
5960 use:combobox .item ={{ value }}
6061 >
6162 <span class ="block truncate" >{value .name }</span >
62- <span class =" absolute invisible group-aria-selected:visible inset-y-0 left-0 flex items-center pl-3 text-teal-600 group-focus: text-white " >
63+ <span class ="absolute invisible group-aria-selected:visible inset-y-0 left-0 flex items-center pl-3 { active ? ' text-white ' : ' text-teal-600 ' } " >
6364 <Check class =" h-5 w-5" />
6465 </span >
6566 </li >
Original file line number Diff line number Diff line change 7070 class =" absolute mt-1 max-h-60 w-full overflow-auto rounded-md bg-white py-1 text-sm shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none"
7171 >
7272 {#each filtered as value }
73+ {@const active = $combobox .active === value }
7374 <li
74- class =" relative cursor-default select-none py-2 pl-4 pr-9 focus:outline-none font-normal aria-selected:font-medium text-gray-900 focus: bg-teal-600 focus: text-white group"
75+ class ="relative cursor-default select-none py-2 pl-4 pr-9 focus:outline-none font-normal aria-selected:font-medium { active ? ' bg-teal-600 text-white' : ' text-gray-900 ' } group"
7576 use:combobox .item ={{ value }}
7677 >
7778 <span class ="block truncate" >{value .name }</span >
78- <span class =" absolute invisible group-aria-selected:visible inset-y-0 right-0 flex items-center pr-3 text-teal-600 group-hover: text-white " >
79+ <span class ="absolute invisible group-aria-selected:visible inset-y-0 right-0 flex items-center pr-3 { active ? ' text-white ' : ' text-teal-600 ' } " >
7980 <Check class =" h-5 w-5" />
8081 </span >
8182 </li >
You can’t perform that action at this time.
0 commit comments