From b239fb1a13d6a816009d5d9c005810e8df3afb6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Oddsson?= Date: Wed, 7 Aug 2024 10:49:34 +0200 Subject: [PATCH 1/2] Only set `aria-hidden` if the drawer is actually hidden --- src/components/drawer/index.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/components/drawer/index.ts b/src/components/drawer/index.ts index 74b397be3..e75225b0c 100644 --- a/src/components/drawer/index.ts +++ b/src/components/drawer/index.ts @@ -55,7 +55,9 @@ class Drawer implements DrawerInterface { init() { // set initial accessibility attributes if (this._targetEl && !this._initialized) { - this._targetEl.setAttribute('aria-hidden', 'true'); + if (this.isHidden()) { + this._targetEl.setAttribute('aria-hidden', 'true'); + } this._targetEl.classList.add('transition-transform'); // set base placement classes From ec0c2e00be8a3765d0af3a4d0aec37a3092c4e75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Oddsson?= Date: Wed, 7 Aug 2024 10:50:03 +0200 Subject: [PATCH 2/2] set visible state based off the viewport size --- src/components/drawer/index.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/drawer/index.ts b/src/components/drawer/index.ts index e75225b0c..289ed2d28 100644 --- a/src/components/drawer/index.ts +++ b/src/components/drawer/index.ts @@ -41,7 +41,11 @@ class Drawer implements DrawerInterface { : targetEl.id; this._targetEl = targetEl; this._options = { ...Default, ...options }; - this._visible = false; + + + const smallViewportSize = getComputedStyle(document.body).getPropertyValue('--small-viewport') || '640px'; + this._visible = !window.matchMedia(`(max-width: ${smallViewportSize})`).matches; + this._initialized = false; this.init(); instances.addInstance(