@@ -239,19 +239,29 @@ export function getPropGetters<
239239 } ;
240240 } ;
241241
242- const getLabelProps : GetLabelProps = ( rest ) => {
242+ const getAutocompleteId = ( instanceId : string , sourceId ?: number ) => {
243+ return typeof sourceId !== 'undefined'
244+ ? `${ instanceId } -${ sourceId } `
245+ : instanceId ;
246+ } ;
247+
248+ const getLabelProps : GetLabelProps = ( providedProps ) => {
249+ const { sourceIndex, ...rest } = providedProps || { } ;
250+
243251 return {
244- htmlFor : `${ props . id } -input` ,
245- id : `${ props . id } -label` ,
252+ htmlFor : `${ getAutocompleteId ( props . id , sourceIndex ) } -input` ,
253+ id : `${ getAutocompleteId ( props . id , sourceIndex ) } -label` ,
246254 ...rest ,
247255 } ;
248256 } ;
249257
250- const getListProps : GetListProps = ( rest ) => {
258+ const getListProps : GetListProps = ( providedProps ) => {
259+ const { sourceIndex, ...rest } = providedProps || { } ;
260+
251261 return {
252262 role : 'listbox' ,
253- 'aria-labelledby' : `${ props . id } -label` ,
254- id : `${ props . id } -list` ,
263+ 'aria-labelledby' : `${ getAutocompleteId ( props . id , sourceIndex ) } -label` ,
264+ id : `${ getAutocompleteId ( props . id , sourceIndex ) } -list` ,
255265 ...rest ,
256266 } ;
257267 } ;
@@ -272,10 +282,12 @@ export function getPropGetters<
272282 } ;
273283
274284 const getItemProps : GetItemProps < any , TMouseEvent > = ( providedProps ) => {
275- const { item, source, ...rest } = providedProps ;
285+ const { item, source, sourceIndex , ...rest } = providedProps ;
276286
277287 return {
278- id : `${ props . id } -item-${ item . __autocomplete_id } ` ,
288+ id : `${ getAutocompleteId ( props . id , sourceIndex as number ) } -item-${
289+ item . __autocomplete_id
290+ } `,
279291 role : 'option' ,
280292 'aria-selected' : store . getState ( ) . activeItemId === item . __autocomplete_id ,
281293 onMouseMove ( event ) {
0 commit comments