@@ -25,14 +25,14 @@ const nuxtLinkComponent = resolveComponent('NuxtLink')
2525
2626const previouslyFocused = shallowRef <HTMLElement | null >(null )
2727
28- const dialogId = ' command-palette-modal'
29- const inputId = ` ${dialogId }-input `
30- const descriptionId = ` ${dialogId }-description `
31- const statusId = ` ${dialogId }-status `
32- const announcementId = ` ${dialogId }-announcement `
33- const resultsId = ` ${dialogId }-results `
34-
35- const inputDescribedBy = computed (() => ` ${descriptionId } ${statusId } ` )
28+ const DIALOG_ID = ' command-palette-modal'
29+ const INPUT_ID = ` ${DIALOG_ID }-input `
30+ const DESCRIPTION_ID = ` ${DIALOG_ID }-description `
31+ const STATUS_ID = ` ${DIALOG_ID }-status `
32+ const ANNOUNCEMENT_ID = ` ${DIALOG_ID }-announcement `
33+ const RESULTS_ID = ` ${DIALOG_ID }-results `
34+
35+ const inputDescribedBy = computed (() => ` ${DESCRIPTION_ID } ${STATUS_ID } ` )
3636const statusContextLabel = computed (() =>
3737 view .value === ' root' ? $t (' command_palette.title' ) : viewMeta .value .placeholder ,
3838)
@@ -63,11 +63,11 @@ const statusMessage = computed(() => {
6363})
6464
6565function getDialog() {
66- return document .querySelector <HTMLDialogElement >(` #${dialogId } ` )
66+ return document .querySelector <HTMLDialogElement >(` #${DIALOG_ID } ` )
6767}
6868
6969function getInputElement() {
70- return document .querySelector <HTMLInputElement >(` #${inputId } ` )
70+ return document .querySelector <HTMLInputElement >(` #${INPUT_ID } ` )
7171}
7272
7373function isInputEventTarget(target : EventTarget | null ) {
@@ -280,26 +280,26 @@ useEventListener(document, 'keydown', handleGlobalKeydown)
280280
281281<template >
282282 <div >
283- <p :id =" announcementId " class =" sr-only" role =" status" aria-live =" polite" aria-atomic =" true" >
283+ <p :id =" ANNOUNCEMENT_ID " class =" sr-only" role =" status" aria-live =" polite" aria-atomic =" true" >
284284 {{ announcement }}
285285 </p >
286286
287287 <!-- noScroll: the results div handles its own scroll; without this, Safari shows
288288 a second scrollbar on the dialog element -->
289289 <Modal
290290 ref =" modalRef"
291- :id =" dialogId "
291+ :id =" DIALOG_ID "
292292 :modalTitle =" $t('command_palette.title')"
293293 :modalSubtitle =" viewMeta.subtitle"
294294 class =" mx-auto mb-0 mt-4 max-w-[48rem] p-0 sm:mt-[10vh]"
295295 no-scroll
296296 @close =" handleDialogClose"
297297 >
298298 <div v-if =" isOpen" class =" -mx-6 -mt-6" >
299- <p :id =" descriptionId " class =" sr-only" >
299+ <p :id =" DESCRIPTION_ID " class =" sr-only" >
300300 {{ $t('command_palette.instructions') }}
301301 </p >
302- <p :id =" statusId " class =" sr-only" role =" status" aria-live =" polite" aria-atomic =" true" >
302+ <p :id =" STATUS_ID " class =" sr-only" role =" status" aria-live =" polite" aria-atomic =" true" >
303303 {{ statusMessage }}
304304 </p >
305305
@@ -316,9 +316,9 @@ useEventListener(document, 'keydown', handleGlobalKeydown)
316316 />
317317 {{ $t('command_palette.back') }}
318318 </button >
319- <label :for =" inputId " class =" sr-only" >{{ $t('command_palette.input_label') }}</label >
319+ <label :for =" INPUT_ID " class =" sr-only" >{{ $t('command_palette.input_label') }}</label >
320320 <InputBase
321- :id =" inputId "
321+ :id =" INPUT_ID "
322322 ref =" inputRef"
323323 v-model =" query"
324324 type =" text"
@@ -327,12 +327,12 @@ useEventListener(document, 'keydown', handleGlobalKeydown)
327327 size =" lg"
328328 class =" w-full"
329329 :aria-describedby =" inputDescribedBy"
330- :aria-controls =" resultsId "
330+ :aria-controls =" RESULTS_ID "
331331 />
332332 </div >
333333
334334 <div
335- :id =" resultsId "
335+ :id =" RESULTS_ID "
336336 class =" max-h-[60vh] overflow-y-auto bg-bg-muted/30 px-2 py-2 sm:px-3 sm:py-3"
337337 :aria-label =" $t('command_palette.results_label')"
338338 role =" region"
@@ -356,7 +356,7 @@ useEventListener(document, 'keydown', handleGlobalKeydown)
356356 class =" rounded-xl border border-border/70 bg-bg-subtle/70 p-1 sm:p-1.5"
357357 >
358358 <h3
359- :id =" `${dialogId }-group-${group.id}`"
359+ :id =" `${DIALOG_ID }-group-${group.id}`"
360360 class =" px-3 pb-2 pt-2 text-sm uppercase tracking-[0.14em] text-fg-subtle"
361361 >
362362 {{ group.label }}
0 commit comments