From 86c831d73355084919a5ff0495895a49cfe6eaa7 Mon Sep 17 00:00:00 2001 From: Sarah Higley Date: Thu, 9 Sep 2021 09:07:49 -0700 Subject: [PATCH] fix(Dropdown): add aria-live only when focused (#19667) --- ...i-react-87609c16-e599-49cf-91e0-2ac09923a565.json | 7 +++++++ .../ChoiceGroup.Custom.Example.tsx.shot | 2 -- .../DetailsList.CustomGroupHeaders.Example.tsx.shot | 2 -- .../__snapshots__/Dropdown.Basic.Example.tsx.shot | 6 ------ .../Dropdown.Controlled.Example.tsx.shot | 2 -- .../Dropdown.ControlledMulti.Example.tsx.shot | 2 -- .../__snapshots__/Dropdown.Custom.Example.tsx.shot | 4 ---- .../__snapshots__/Dropdown.Error.Example.tsx.shot | 2 -- .../__snapshots__/Dropdown.Required.Example.tsx.shot | 4 ---- .../__snapshots__/Facepile.Basic.Example.tsx.shot | 2 -- .../__snapshots__/Facepile.Overflow.Example.tsx.shot | 2 -- .../ResizeGroup.OverflowSet.Example.tsx.shot | 2 -- .../react/src/components/Dropdown/Dropdown.base.tsx | 6 +++--- .../react/src/components/Dropdown/Dropdown.test.tsx | 12 ++++++++++++ .../Dropdown/__snapshots__/Dropdown.test.tsx.snap | 8 -------- 15 files changed, 22 insertions(+), 41 deletions(-) create mode 100644 change/@fluentui-react-87609c16-e599-49cf-91e0-2ac09923a565.json diff --git a/change/@fluentui-react-87609c16-e599-49cf-91e0-2ac09923a565.json b/change/@fluentui-react-87609c16-e599-49cf-91e0-2ac09923a565.json new file mode 100644 index 00000000000000..04dce1c95fa78e --- /dev/null +++ b/change/@fluentui-react-87609c16-e599-49cf-91e0-2ac09923a565.json @@ -0,0 +1,7 @@ +{ + "type": "patch", + "comment": "Fix Dropdown to only add ARIA live region when focused", + "packageName": "@fluentui/react", + "email": "sarah.higley@microsoft.com", + "dependentChangeType": "patch" +} diff --git a/packages/react-examples/src/react/__snapshots__/ChoiceGroup.Custom.Example.tsx.shot b/packages/react-examples/src/react/__snapshots__/ChoiceGroup.Custom.Example.tsx.shot index cb2272c7c37e6d..0d14f7e355ac7f 100644 --- a/packages/react-examples/src/react/__snapshots__/ChoiceGroup.Custom.Example.tsx.shot +++ b/packages/react-examples/src/react/__snapshots__/ChoiceGroup.Custom.Example.tsx.shot @@ -279,9 +279,7 @@ exports[`Component Examples renders ChoiceGroup.Custom.Example.tsx correctly 1`] tabIndex={-1} > { diff --git a/packages/react/src/components/Dropdown/Dropdown.test.tsx b/packages/react/src/components/Dropdown/Dropdown.test.tsx index 8f9ce4f6a64112..dd316af8cfce94 100644 --- a/packages/react/src/components/Dropdown/Dropdown.test.tsx +++ b/packages/react/src/components/Dropdown/Dropdown.test.tsx @@ -147,6 +147,18 @@ describe('Dropdown', () => { expect(titleElement.text()).toEqual('1'); }); + it('Renders live region attributes only when focused', () => { + wrapper = mount(); + let titleElement = wrapper.find('.ms-Dropdown-title'); + + expect(titleElement.props()['aria-live']).toBeUndefined(); + + wrapper.find('.ms-Dropdown').simulate('focus'); + titleElement = wrapper.find('.ms-Dropdown-title'); + + expect(titleElement.props()['aria-live']).toEqual('polite'); + }); + it('does not change the selected item in when defaultSelectedKey changes', () => { wrapper = mount(); const titleElement = wrapper.find('.ms-Dropdown-title'); diff --git a/packages/react/src/components/Dropdown/__snapshots__/Dropdown.test.tsx.snap b/packages/react/src/components/Dropdown/__snapshots__/Dropdown.test.tsx.snap index f950491999d356..a2b32c7f96889e 100644 --- a/packages/react/src/components/Dropdown/__snapshots__/Dropdown.test.tsx.snap +++ b/packages/react/src/components/Dropdown/__snapshots__/Dropdown.test.tsx.snap @@ -106,9 +106,7 @@ exports[`Dropdown multi-select Renders correctly 1`] = ` tabIndex={0} >