From 201189e079f2e274dedbc0ef7e7a7ec7968c60bd Mon Sep 17 00:00:00 2001 From: Daniel Richards Date: Wed, 21 Sep 2022 16:20:39 +0800 Subject: [PATCH] Add role=application to list view to prevent browse mode triggering in NVDA (#44291) * Add role=application to list view to prevent browse mode triggering in NVDA * Move the aria-label to application role. * Add aria-label back to table for now. This broke too many E2E and this fix should make release. * Update snapshots Co-authored-by: Alex Stine --- .../src/components/list-view/index.js | 1 + packages/components/src/tree-grid/index.js | 37 +++++++++++------- .../tree-grid/test/__snapshots__/cell.js.snap | 38 ++++++++++--------- .../test/__snapshots__/index.js.snap | 2 +- 4 files changed, 46 insertions(+), 32 deletions(-) diff --git a/packages/block-editor/src/components/list-view/index.js b/packages/block-editor/src/components/list-view/index.js index bd077eb3cb8239..7166b594c276c2 100644 --- a/packages/block-editor/src/components/list-view/index.js +++ b/packages/block-editor/src/components/list-view/index.js @@ -188,6 +188,7 @@ function ListView( onCollapseRow={ collapseRow } onExpandRow={ expandRow } onFocusRow={ focusRow } + applicationAriaLabel={ __( 'Block navigation structure' ) } > {}, onCollapseRow = () => {}, onFocusRow = () => {}, + applicationAriaLabel, ...props }, ref @@ -286,14 +288,21 @@ function TreeGrid( /* eslint-disable jsx-a11y/no-noninteractive-element-to-interactive-role */ return ( - - { children } -
+ { + // Prevent browser mode from triggering in NVDA by wrapping List View + // in a role=application wrapper. + // see: https://github.com/WordPress/gutenberg/issues/43729 + } +
+ + { children } +
+
); /* eslint-enable jsx-a11y/no-noninteractive-element-to-interactive-role */ diff --git a/packages/components/src/tree-grid/test/__snapshots__/cell.js.snap b/packages/components/src/tree-grid/test/__snapshots__/cell.js.snap index 23d0568807b04d..7817c3259bf5aa 100644 --- a/packages/components/src/tree-grid/test/__snapshots__/cell.js.snap +++ b/packages/components/src/tree-grid/test/__snapshots__/cell.js.snap @@ -1,23 +1,27 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`TreeGridCell uses a child render function to render children 1`] = ` - - - - + + - - -
-
- Click Me! - -
+ + + + + + `; diff --git a/packages/components/src/tree-grid/test/__snapshots__/index.js.snap b/packages/components/src/tree-grid/test/__snapshots__/index.js.snap index db862583f22e01..f493168bdb933e 100644 --- a/packages/components/src/tree-grid/test/__snapshots__/index.js.snap +++ b/packages/components/src/tree-grid/test/__snapshots__/index.js.snap @@ -1,3 +1,3 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`TreeGrid simple rendering renders a table, tbody and any child elements 1`] = `"
Test
"`; +exports[`TreeGrid simple rendering renders a table, tbody and any child elements 1`] = `"
Test
"`;