File tree 1 file changed +12
-11
lines changed
src/lib/components/command 1 file changed +12
-11
lines changed Original file line number Diff line number Diff line change 34
34
let acted = false ;
35
35
36
36
beforeNavigate (({ complete }) => {
37
- complete .then (acted ? callback : null );
37
+ acted && complete .then (null );
38
38
});
39
39
</script >
40
40
57
57
{:else if item .type === " link" }
58
58
59
59
<Command .Item onSelect ={() => acted = true } asChild let:action let:attrs >
60
+ {@const highlighted = attrs [" data-selected" ]}
60
61
<!-- 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 >
63
64
{item .text }
64
65
</a >
65
66
</Command .Item >
66
67
67
68
{:else if item .type === " cmd" }
68
69
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" ]}>
71
72
{item .text }
72
73
</button >
73
74
</Command .Item >
74
75
75
76
{/if }
76
77
77
78
<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
+ }
81
82
82
- .selected {
83
- --uno : bg-white/5 ;
84
- }
83
+ .highlighted {
84
+ --uno : bg-white/5 ;
85
+ }
85
86
</style >
You can’t perform that action at this time.
0 commit comments