Skip to content

Commit aabc1ef

Browse files
committed
feat(select): add inputId prop
1 parent a51c35c commit aabc1ef

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,10 @@ Teleport the menu outside of the component DOM tree. You can pass a valid string
102102

103103
**Note**: top and left properties are calculated using a ref on the `.vue-select` with a `container.getBoundingClientRect()`.
104104

105+
**inputId**: `string` (default: `undefined`)
106+
107+
The `id` attribute to be passed to the `<input />` element. This is useful for accessibility or forms.
108+
105109
**aria**: `{ labelledby?: string; required?: boolean; }` (default: `undefined`)
106110

107111
Aria attributes to be passed to the select control to improve accessibility.

src/Select.vue

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ const props = withDefaults(
4545
* JavaScript, instead of using CSS absolute & relative positioning.
4646
*/
4747
teleport?: string;
48+
/**
49+
* The ID of the input element. This is useful for accessibility or forms.
50+
*/
51+
inputId?: string;
4852
/**
4953
* ARIA attributes to describe the select component. This is useful for accessibility.
5054
*/
@@ -89,6 +93,7 @@ const props = withDefaults(
8993
isMulti: false,
9094
closeOnSelect: true,
9195
teleport: undefined,
96+
inputId: undefined,
9297
aria: undefined,
9398
filterBy: (option: Option, label: string, search: string) => label.toLowerCase().includes(search.toLowerCase()),
9499
getOptionLabel: (option: Option) => option.label,
@@ -346,6 +351,7 @@ onBeforeUnmount(() => {
346351
</template>
347352

348353
<input
354+
:id="inputId"
349355
ref="input"
350356
v-model="search"
351357
class="search-input"

0 commit comments

Comments
 (0)