Skip to content

Commit 69066fe

Browse files
committed
fix(ui): render kbd hints during SSR to prevent layout shift
1 parent 1dcbde9 commit 69066fe

2 files changed

Lines changed: 16 additions & 22 deletions

File tree

app/components/Button/Base.vue

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ const props = withDefaults(
2626
2727
const el = useTemplateRef('el')
2828
29-
const keyboardShortcuts = useKeyboardShortcuts()
30-
const keyboardShortcutsEnabled = computed(() => import.meta.client && keyboardShortcuts.value)
29+
const keyboardShortcutsEnabled = useKeyboardShortcuts()
3130
3231
defineExpose({
3332
focus: () => el.value?.focus(),
@@ -63,14 +62,12 @@ defineExpose({
6362
>
6463
<span v-if="classicon" class="size-[1em]" :class="classicon" aria-hidden="true" />
6564
<slot />
66-
<ClientOnly>
67-
<kbd
68-
v-if="keyboardShortcutsEnabled && ariaKeyshortcuts"
69-
class="ms-2 inline-flex items-center justify-center w-4 h-4 text-xs text-fg bg-bg-muted border border-border rounded no-underline"
70-
aria-hidden="true"
71-
>
72-
{{ ariaKeyshortcuts }}
73-
</kbd>
74-
</ClientOnly>
65+
<kbd
66+
v-if="keyboardShortcutsEnabled && ariaKeyshortcuts"
67+
class="ms-2 inline-flex items-center justify-center w-4 h-4 text-xs text-fg bg-bg-muted border border-border rounded no-underline"
68+
aria-hidden="true"
69+
>
70+
{{ ariaKeyshortcuts }}
71+
</kbd>
7572
</button>
7673
</template>

app/components/Link/Base.vue

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,7 @@ const isLink = computed(() => props.variant === 'link')
5959
const isButton = computed(() => !isLink.value)
6060
const isButtonSmall = computed(() => props.size === 'small' && !isLink.value)
6161
const isButtonMedium = computed(() => props.size === 'medium' && !isLink.value)
62-
const keyboardShortcuts = useKeyboardShortcuts()
63-
const keyboardShortcutsEnabled = computed(() => import.meta.client && keyboardShortcuts.value)
62+
const keyboardShortcutsEnabled = useKeyboardShortcuts()
6463
</script>
6564

6665
<template>
@@ -115,14 +114,12 @@ const keyboardShortcutsEnabled = computed(() => import.meta.client && keyboardSh
115114
class="i-lucide:link size-[1em] opacity-0 group-hover/link:opacity-100 transition-opacity duration-200"
116115
aria-hidden="true"
117116
/>
118-
<ClientOnly>
119-
<kbd
120-
v-if="keyboardShortcutsEnabled && ariaKeyshortcuts"
121-
class="ms-2 inline-flex items-center justify-center size-4 text-xs text-fg bg-bg-muted border border-border rounded no-underline"
122-
aria-hidden="true"
123-
>
124-
{{ ariaKeyshortcuts }}
125-
</kbd>
126-
</ClientOnly>
117+
<kbd
118+
v-if="keyboardShortcutsEnabled && ariaKeyshortcuts"
119+
class="ms-2 inline-flex items-center justify-center size-4 text-xs text-fg bg-bg-muted border border-border rounded no-underline"
120+
aria-hidden="true"
121+
>
122+
{{ ariaKeyshortcuts }}
123+
</kbd>
127124
</NuxtLink>
128125
</template>

0 commit comments

Comments
 (0)