Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
fix(dashboard): keep Shift+Tab inside a dialog from its card
Yudhi Armyndharisdaf7a4eafa54
diff --git a/dashboard/src/utils/modalA11y.test.ts b/dashboard/src/utils/modalA11y.test.tsindex 18979e8a4..732b36830 100644--- a/dashboard/src/utils/modalA11y.test.ts+++ b/dashboard/src/utils/modalA11y.test.ts@@ -345,3 +345,23 @@ test('a lower dialog does not handle Tab while the nested dialog owns focus', ()unbindParent();}});++test('Shift+Tab from the dialog card wraps to the last control, and Tab from it is left to the browser', () => {+ const { doc, card, focusables } = makeWorld(2);+ const unbind = bindModalA11y(doc as never, card as never, () => {});+ try {+ card.focus();+ const back = makeKeyEvent('Tab', true);+ doc.dispatchKey(back);+ assert.equal(back.defaultPrevented, true);+ assert.equal(doc.activeElement, focusables[1] as never);++ card.focus();+ const forward = makeKeyEvent('Tab');+ doc.dispatchKey(forward);+ assert.equal(forward.defaultPrevented, false);+ assert.equal(doc.activeElement, card as never);+ } finally {+ unbind();+ }+});diff --git a/dashboard/src/utils/modalA11y.ts b/dashboard/src/utils/modalA11y.tsindex d9e4879c8..d272d9400 100644--- a/dashboard/src/utils/modalA11y.ts+++ b/dashboard/src/utils/modalA11y.ts@@ -69,7 +69,8 @@ export function bindModalA11y(if (!card.contains(doc.activeElement)) {event.preventDefault();(event.shiftKey ? last : first).focus();- } else if (event.shiftKey && doc.activeElement === first) {+ } else if (event.shiftKey && (doc.activeElement === first || doc.activeElement === card)) {+ // The card is focusable itself (a click on dialog text lands there), and Shift+Tab from it would leave.event.preventDefault();last.focus();} else if (!event.shiftKey && doc.activeElement === last) {