Repository: algolia/autocomplete (TypeScript)

Issue:
The `aria-controls` attribute isn't returned by getRootProps
## Description

[The createAutocomplete function](https://www.algolia.com/doc/ui-libraries/autocomplete/api-reference/autocomplete-core/createAutocomplete/) `getRootProps()` getter doesn't return the `aria-controls` attribute.

This is flagged as a violation by Axe Core.

![image](https://github.com/user-attachments/assets/73eaeb7a-acab-4521-a797-3d0ae45e5f7a)

## Reproduction

You can reproduce this issue in the Algolia docs: https://www.algolia.com/doc/.

**Steps**

1. Go to https://www.algolia.com/doc/
2. Click on "Search for documentation" trigger button
3. Search for any keyword that displays results
4. Use the Axe DevTools browser extension to run a scan and see the "Required Aria attributes must be provided" issue (as per the screenshot above).

## Expected behavior

Is it a false positive because the `aria-controls` attribute is [returned by the `getInputProps` getter](https://github.com/algolia/autocomplete/blob/9658a4dcae46b6a92732dcc3e61efccbd320ba3e/packages/autocomplete-core/src/getPropGetters.ts#L202)?

Or should it also be set on the `combobox` (returned by `getRootProps`)?


## Environment

- Autocomplete version: 1.17.4



Discussion:
following along as well! Had to set this manually to 'aa-Panel', but seems like this'd be an easy thing to fix?
Hi, thanks for your reports. We've updated `getRootProps()` to return `aria-controls`. This change will be available in a few days on the next version of autocomplete.



Patch:
diff --git a/packages/autocomplete-core/src/getPropGetters.ts b/packages/autocomplete-core/src/getPropGetters.ts
index 7615e9f45..da78d2711 100644
--- a/packages/autocomplete-core/src/getPropGetters.ts
+++ b/packages/autocomplete-core/src/getPropGetters.ts
@@ -110,7 +110,7 @@ export function getPropGetters<
       role: 'combobox',
       'aria-expanded': store.getState().isOpen,
       'aria-haspopup': 'listbox',
-      'aria-owns': store.getState().isOpen
+      'aria-controls': store.getState().isOpen
         ? store
             .getState()
             .collections.map(({ source }) =>
diff --git a/packages/autocomplete-shared/src/core/AutocompletePropGetters.ts b/packages/autocomplete-shared/src/core/AutocompletePropGetters.ts
index 6601592ca..5d03f3162 100644
--- a/packages/autocomplete-shared/src/core/AutocompletePropGetters.ts
+++ b/packages/autocomplete-shared/src/core/AutocompletePropGetters.ts
@@ -42,7 +42,7 @@ export type GetRootProps = (props?: { [key: string]: unknown }) => {
     | 'listbox'
     | 'tree'
     | undefined;
-  'aria-owns': string | undefined;
+  'aria-controls': string | undefined;
   'aria-labelledby': string;
 };
 


Test patch:
diff --git a/packages/autocomplete-core/src/__tests__/getRootProps.test.ts b/packages/autocomplete-core/src/__tests__/getRootProps.test.ts
index 5a5fee2c6..c8ca4a2cd 100644
--- a/packages/autocomplete-core/src/__tests__/getRootProps.test.ts
+++ b/packages/autocomplete-core/src/__tests__/getRootProps.test.ts
@@ -45,7 +45,7 @@ describe('getRootProps', () => {
     expect(rootProps['aria-haspopup']).toEqual('listbox');
   });
 
-  test('returns undefined aria-owns when panel is closed', () => {
+  test('returns undefined aria-controls when panel is closed', () => {
     const autocomplete = createAutocomplete({
       initialState: {
         isOpen: false,
@@ -53,10 +53,10 @@ describe('getRootProps', () => {
     });
     const rootProps = autocomplete.getRootProps({});
 
-    expect(rootProps['aria-owns']).toBeUndefined();
+    expect(rootProps['aria-controls']).toBeUndefined();
   });
 
-  test('returns list id in aria-owns when panel is open', () => {
+  test('returns list id in aria-controls when panel is open', () => {
     const autocomplete = createAutocomplete({
       id: 'autocomplete',
       initialState: {
@@ -70,7 +70,7 @@ describe('getRootProps', () => {
     });
     const rootProps = autocomplete.getRootProps({});
 
-    expect(rootProps['aria-owns']).toEqual('autocomplete-testSource-list');
+    expect(rootProps['aria-controls']).toEqual('autocomplete-testSource-list');
   });
 
   test('returns label id in aria-labelledby', () => {