fix: commands wont focus, popover cant reverse
This commit is contained in:
2 files changed
+15
-10
No files matched your search
@@ -27,7 +27,7 @@
|
|||||||
profile.data,
|
profile.data,
|
||||||
profileData.profiles,
|
profileData.profiles,
|
||||||
theme.data,
|
theme.data,
|
||||||
page.data.contextual?.actions
|
page.data.contextual?.actions,
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -37,6 +37,7 @@
|
|||||||
let selectedIndex = $state(0)
|
let selectedIndex = $state(0)
|
||||||
let filteredGroups: Group[] = $state([])
|
let filteredGroups: Group[] = $state([])
|
||||||
let breadcrumbs: Action[] = $state([])
|
let breadcrumbs: Action[] = $state([])
|
||||||
|
let input = $state<HTMLInputElement>()
|
||||||
|
|
||||||
function fuzzySearch(text: string, pattern: string): number {
|
function fuzzySearch(text: string, pattern: string): number {
|
||||||
const textLower = text.toLowerCase()
|
const textLower = text.toLowerCase()
|
||||||
@@ -95,7 +96,7 @@
|
|||||||
score: Math.max(
|
score: Math.max(
|
||||||
fuzzySearch(action.name, term),
|
fuzzySearch(action.name, term),
|
||||||
fuzzySearch(group.name, term),
|
fuzzySearch(group.name, term),
|
||||||
action.detail ? fuzzySearch(action.detail, term) : -1
|
action.detail ? fuzzySearch(action.detail, term) : -1,
|
||||||
),
|
),
|
||||||
}))
|
}))
|
||||||
.filter((action) => action.score > 0)
|
.filter((action) => action.score > 0)
|
||||||
@@ -106,7 +107,7 @@
|
|||||||
actions: scoredActions,
|
actions: scoredActions,
|
||||||
score: Math.max(
|
score: Math.max(
|
||||||
fuzzySearch(group.name, term),
|
fuzzySearch(group.name, term),
|
||||||
...scoredActions.map((a) => a.score)
|
...scoredActions.map((a) => a.score),
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -140,7 +141,7 @@
|
|||||||
|
|
||||||
function flattenActions(
|
function flattenActions(
|
||||||
actions: Action[],
|
actions: Action[],
|
||||||
subaction: boolean = true
|
subaction: boolean = true,
|
||||||
): Action[] {
|
): Action[] {
|
||||||
return actions.flatMap((action) => [
|
return actions.flatMap((action) => [
|
||||||
action,
|
action,
|
||||||
@@ -237,13 +238,17 @@
|
|||||||
if (open) search = ''
|
if (open) search = ''
|
||||||
})
|
})
|
||||||
|
|
||||||
let flattenedActions = $derived(
|
|
||||||
filteredGroups.flatMap((group) => group.actions)
|
|
||||||
)
|
|
||||||
|
|
||||||
$effect(() => {
|
$effect(() => {
|
||||||
debouncedSearch(search)
|
debouncedSearch(search)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
onMount(() => {
|
||||||
|
if (input) input.focus()
|
||||||
|
})
|
||||||
|
|
||||||
|
let flattenedActions = $derived(
|
||||||
|
filteredGroups.flatMap((group) => group.actions),
|
||||||
|
)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:window onkeydown={handleKeydown} />
|
<svelte:window onkeydown={handleKeydown} />
|
||||||
@@ -253,6 +258,7 @@
|
|||||||
class="sticky rounded-none border-t-0 border-x-0 focus-within:dark:border-zinc-800"
|
class="sticky rounded-none border-t-0 border-x-0 focus-within:dark:border-zinc-800"
|
||||||
size="lg"
|
size="lg"
|
||||||
placeholder={$t('nav.commands.prompt')}
|
placeholder={$t('nav.commands.prompt')}
|
||||||
|
bind:element={input}
|
||||||
/>
|
/>
|
||||||
<div class="h-[32rem] overflow-auto border-slate-200 dark:border-zinc-800 p-5">
|
<div class="h-[32rem] overflow-auto border-slate-200 dark:border-zinc-800 p-5">
|
||||||
{#if breadcrumbs.length > 0}
|
{#if breadcrumbs.length > 0}
|
||||||
|
|||||||
@@ -124,8 +124,7 @@
|
|||||||
{#if open}
|
{#if open}
|
||||||
<Portal class="z-[150]">
|
<Portal class="z-[150]">
|
||||||
<div
|
<div
|
||||||
in:scale={{ duration: 300, start: 0.97, easing: expoOut }}
|
transition:scale={{ duration: 300, start: 0.97, easing: expoOut }}
|
||||||
out:scale={{ duration: 200, start: 0.95, easing: expoOut }}
|
|
||||||
class="z-[150] {popoverClass}"
|
class="z-[150] {popoverClass}"
|
||||||
use:customFloatingContent
|
use:customFloatingContent
|
||||||
use:focusTrap
|
use:focusTrap
|
||||||
|
|||||||
Reference in new issue
Block a user