Skip to content

Commit f146b47

Browse files
committed
feat: add aria label to selects
1 parent 3cba6e0 commit f146b47

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

app/components/Select/Field.vue

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@ const model = defineModel<string | undefined>({ default: undefined })
2222
export interface SelectFieldProps extends SelectBaseProps {
2323
items: { label: string; value: string; disabled?: boolean }[]
2424
size?: keyof typeof SELECT_FIELD_SIZES
25-
inputAttrs?: HTMLSelectElement['attributes'] & Omit<SelectBaseProps, 'size' | 'id'>
25+
selectAttrs?: Omit<SelectBaseProps, 'size' | 'id'> &
26+
Record<string, string | number | boolean | undefined>
2627
label?: string
27-
labelAttrs?: HTMLSelectElement['attributes'] & Omit<SelectBaseProps, 'size' | 'id'>
28+
labelAttrs?: Record<string, string | number | boolean | undefined>
2829
/** Visually hide label */
2930
hiddenLabel?: boolean
3031
id: string
@@ -54,7 +55,7 @@ const props = withDefaults(defineProps<SelectFieldProps>(), {
5455
class="appearance-none group-hover/select:border-fg-muted"
5556
:class="[SELECT_FIELD_SIZES[size], block ? 'w-full' : 'w-fit']"
5657
v-model="model"
57-
v-bind="inputAttrs"
58+
v-bind="selectAttrs"
5859
:id="id"
5960
>
6061
<option

test/nuxt/a11y.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2301,7 +2301,7 @@ describe('component accessibility audits', () => {
23012301
const component = await mountSuspended(SelectField, {
23022302
props: {
23032303
id: 'a11y-select-3',
2304-
attrs: { 'aria-label': 'Disabled select' },
2304+
selectAttrs: { 'aria-label': 'Disabled select' },
23052305
items: [{ label: 'Option 1', value: 'option1' }],
23062306
disabled: true,
23072307
},
@@ -2314,7 +2314,7 @@ describe('component accessibility audits', () => {
23142314
const component = await mountSuspended(SelectField, {
23152315
props: {
23162316
id: 'a11y-select-4',
2317-
attrs: { 'aria-label': 'Small select' },
2317+
selectAttrs: { 'aria-label': 'Disabled select' },
23182318
items: [{ label: 'Option 1', value: 'option1' }],
23192319
size: 'sm',
23202320
},

0 commit comments

Comments
 (0)