@@ -29,6 +29,9 @@ const getArgsByChildComponent = ({
29
29
menuLoading,
30
30
selectionVariant,
31
31
32
+ // Autocomplete.Input
33
+ openOnFocus,
34
+
32
35
// Autocomplete.Overlay
33
36
anchorSide,
34
37
height,
@@ -65,6 +68,7 @@ any) => {
65
68
}
66
69
return {
67
70
menuArgs : { emptyStateText, loading : menuLoading , selectionVariant} ,
71
+ inputArgs : { openOnFocus} ,
68
72
overlayArgs : { anchorSide, height, maxHeight : overlayMaxHeight , width} ,
69
73
textInputArgs,
70
74
textInputWithTokensArgs : {
@@ -131,6 +135,7 @@ const autocompleteStoryMeta: Meta = {
131
135
emptyStateText : 'No selectable options' ,
132
136
menuLoading : false ,
133
137
selectionVariant : 'single' ,
138
+ openOnFocus : true ,
134
139
anchorSide : undefined ,
135
140
height : 'auto' ,
136
141
overlayMaxHeight : undefined ,
@@ -161,6 +166,16 @@ const autocompleteStoryMeta: Meta = {
161
166
} ,
162
167
} ,
163
168
169
+ // Autocomplete.Input
170
+ openOnFocus : {
171
+ control : {
172
+ type : 'boolean' ,
173
+ } ,
174
+ table : {
175
+ category : 'Autocomplete.Input' ,
176
+ } ,
177
+ } ,
178
+
164
179
// Autocomplete.Overlay
165
180
anchorSide : {
166
181
control : {
@@ -217,7 +232,7 @@ const autocompleteStoryMeta: Meta = {
217
232
218
233
export const Default = ( args : FormControlArgs < AutocompleteArgs > ) => {
219
234
const { parentArgs, labelArgs, captionArgs, validationArgs} = getFormControlArgsByChildComponent ( args )
220
- const { menuArgs, overlayArgs, textInputArgs} = getArgsByChildComponent ( args )
235
+ const { menuArgs, inputArgs , overlayArgs, textInputArgs} = getArgsByChildComponent ( args )
221
236
const isMultiselect = menuArgs . selectionVariant === 'multiple'
222
237
const [ selectedItemIds , setSelectedItemIds ] = useState < Array < string > > ( [ ] )
223
238
const onSelectedChange = ( newlySelectedItems : Datum | Datum [ ] ) => {
@@ -228,12 +243,19 @@ export const Default = (args: FormControlArgs<AutocompleteArgs>) => {
228
243
setSelectedItemIds ( newlySelectedItems . map ( item => item . id ) )
229
244
}
230
245
246
+ const autocompleteInput = { ...inputArgs , ...textInputArgs }
247
+ const formValidationId = 'validation-field'
231
248
return (
232
249
< Box as = "form" sx = { { p : 3 } } onSubmit = { event => event . preventDefault ( ) } >
233
250
< FormControl { ...parentArgs } >
234
251
< FormControl . Label id = "autocompleteLabel" { ...labelArgs } />
235
252
< Autocomplete >
236
- < Autocomplete . Input { ...textInputArgs } size = { textInputArgs . inputSize } data-testid = "autocompleteInput" />
253
+ < Autocomplete . Input
254
+ aria-describedby = { formValidationId }
255
+ { ...autocompleteInput }
256
+ size = { textInputArgs . inputSize }
257
+ data-testid = "autocompleteInput"
258
+ />
237
259
< Autocomplete . Overlay { ...overlayArgs } >
238
260
< Autocomplete . Menu
239
261
items = { items }
@@ -246,7 +268,7 @@ export const Default = (args: FormControlArgs<AutocompleteArgs>) => {
246
268
</ Autocomplete >
247
269
{ captionArgs . children && < FormControl . Caption { ...captionArgs } /> }
248
270
{ validationArgs . children && validationArgs . variant && (
249
- < FormControl . Validation { ...validationArgs } variant = { validationArgs . variant } />
271
+ < FormControl . Validation id = { formValidationId } { ...validationArgs } variant = { validationArgs . variant } />
250
272
) }
251
273
</ FormControl >
252
274
</ Box >
0 commit comments