From 44c4a2520042cc58a3d70faf832d48642ca0172e Mon Sep 17 00:00:00 2001 From: Sarah Higley Date: Wed, 5 Apr 2023 16:00:41 -0700 Subject: [PATCH 1/3] fix: ComboBox does not update activeDescendant --- .../src/components/ComboBox/ComboBox.test.tsx | 18 ++++++++++++++++++ .../react/src/components/ComboBox/ComboBox.tsx | 6 +++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/packages/react/src/components/ComboBox/ComboBox.test.tsx b/packages/react/src/components/ComboBox/ComboBox.test.tsx index 6356b5153c09df..2831eb23204322 100644 --- a/packages/react/src/components/ComboBox/ComboBox.test.tsx +++ b/packages/react/src/components/ComboBox/ComboBox.test.tsx @@ -530,6 +530,24 @@ describe('ComboBox', () => { expect(combobox.getAttribute('value')).toEqual('One'); }); + it('Updates aria-activedescendant with keyboard', () => { + const options: IComboBoxOption[] = [ + { key: '1', text: '1', id: 'one' }, + { key: '2', text: '2', id: 'two' }, + { key: '3', text: '3', id: 'three' }, + ]; + const { getByRole } = render(); + const combobox = getByRole('combobox'); + // open combobox + userEvent.tab(); + userEvent.keyboard('{enter}'); + expect(combobox.getAttribute('aria-expanded')).toEqual('true'); + + // arrow down + userEvent.keyboard('{arrowdown}'); + expect(combobox.getAttribute('aria-activedescendant')).toEqual('two'); + }); + it('Cannot insert text while disabled', () => { const { getByRole } = render(); const combobox = getByRole('combobox'); diff --git a/packages/react/src/components/ComboBox/ComboBox.tsx b/packages/react/src/components/ComboBox/ComboBox.tsx index ac7e4fa8f33a60..8c4f9ce65d5146 100644 --- a/packages/react/src/components/ComboBox/ComboBox.tsx +++ b/packages/react/src/components/ComboBox/ComboBox.tsx @@ -425,11 +425,11 @@ class ComboBoxInternal extends React.Component Date: Wed, 5 Apr 2023 16:01:55 -0700 Subject: [PATCH 2/3] change file --- ...luentui-react-d4744099-358e-4a73-991b-8d917fc90753.json | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 change/@fluentui-react-d4744099-358e-4a73-991b-8d917fc90753.json diff --git a/change/@fluentui-react-d4744099-358e-4a73-991b-8d917fc90753.json b/change/@fluentui-react-d4744099-358e-4a73-991b-8d917fc90753.json new file mode 100644 index 00000000000000..1a30dee6bdfd53 --- /dev/null +++ b/change/@fluentui-react-d4744099-358e-4a73-991b-8d917fc90753.json @@ -0,0 +1,7 @@ +{ + "type": "patch", + "comment": "fix: ComboBox updates activeDescendant value", + "packageName": "@fluentui/react", + "email": "sarah.higley@microsoft.com", + "dependentChangeType": "patch" +} From c19d11592e563cd8ee5ec889a6c47a893759dc9f Mon Sep 17 00:00:00 2001 From: Sarah Higley Date: Wed, 5 Apr 2023 16:16:49 -0700 Subject: [PATCH 3/3] check initial activedesc value in test Co-authored-by: Makoto Morimoto --- packages/react/src/components/ComboBox/ComboBox.test.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/react/src/components/ComboBox/ComboBox.test.tsx b/packages/react/src/components/ComboBox/ComboBox.test.tsx index 2831eb23204322..cd1c4eb315c519 100644 --- a/packages/react/src/components/ComboBox/ComboBox.test.tsx +++ b/packages/react/src/components/ComboBox/ComboBox.test.tsx @@ -542,6 +542,7 @@ describe('ComboBox', () => { userEvent.tab(); userEvent.keyboard('{enter}'); expect(combobox.getAttribute('aria-expanded')).toEqual('true'); + expect(combobox.getAttribute('aria-activedescendant')).toEqual('one'); // arrow down userEvent.keyboard('{arrowdown}');