File tree Expand file tree Collapse file tree 1 file changed +12
-11
lines changed
src/lib/components/command Expand file tree Collapse file tree 1 file changed +12
-11
lines changed Original file line number Diff line number Diff line change 3434 let acted = false ;
3535
3636 beforeNavigate (({ complete }) => {
37- complete .then (acted ? callback : null );
37+ acted && complete .then (null );
3838 });
3939 </script >
4040
5757{:else if item .type === " link" }
5858
5959 <Command .Item onSelect ={() => acted = true } asChild let:action let:attrs >
60+ {@const highlighted = attrs [" data-selected" ]}
6061 <!-- eslint-disable-next-line no-unused-vars -->
61- {@const _ = (browser && attrs [ " data-selected " ] && preloadData (item .href ))}
62- <a href ={item .href } use:action {...attrs } class:selected ={ attrs [ " data-selected " ]} >
62+ {@const _ = (browser && highlighted && preloadData (item .href ))}
63+ <a href ={item .href } use:action {...attrs } class:highlighted >
6364 {item .text }
6465 </a >
6566 </Command .Item >
6667
6768{:else if item .type === " cmd" }
6869
69- <Command .Item onSelect ={value => item .callback (value ). then (() => acted = true )} asChild let:action let:attrs >
70- <button use:action {...attrs } class:selected ={attrs [" data-selected" ]}>
70+ <Command .Item onSelect ={value => ( async () => item .callback (value ))(). finally ( callback )} asChild let:action let:attrs >
71+ <button use:action {...attrs } class:highlighted ={attrs [" data-selected" ]}>
7172 {item .text }
7273 </button >
7374 </Command .Item >
7475
7576{/if }
7677
7778<style >
78- a , button {
79- --uno : block w-full rounded-md p-2 -mx-2;
80- }
79+ a , button {
80+ --uno : block w-full rounded-md p-2 -mx-2;
81+ }
8182
82- .selected {
83- --uno : bg-white/5 ;
84- }
83+ .highlighted {
84+ --uno : bg-white/5 ;
85+ }
8586 </style >
You can’t perform that action at this time.
0 commit comments