From ca14a75175f0b72f596b364209d8d15b55ad439b Mon Sep 17 00:00:00 2001 From: Mitchell Austin Date: Mon, 21 Aug 2023 22:12:10 -0700 Subject: [PATCH] Add hack for Chromium bug --- packages/components/src/modal/aria-helper.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/components/src/modal/aria-helper.ts b/packages/components/src/modal/aria-helper.ts index 0c059baf713696..8d554a16521f99 100644 --- a/packages/components/src/modal/aria-helper.ts +++ b/packages/components/src/modal/aria-helper.ts @@ -67,4 +67,14 @@ export function unmodalize() { for ( const element of hiddenElements ) { element.removeAttribute( 'inert' ); } + + // Hacks around a Chromium bug where it may fail to restore a region to the + // accessibility tree after an ancestor had the `inert` attribute removed. + // The bug seems like a variation of this: https://crbug.com/1354313 + // This workaround doesn't have to be a custom property. It also seems to + // not have to be done each invocation but it's inexpensive and ensures + // some other code didn't remove it. + document + .querySelectorAll< HTMLElement >( '[role=region]' ) + .forEach( ( region ) => region.style.setProperty( '--∞', '8' ) ); }