Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
fix(dashboard): keep toasts above the media lightbox
Yudhi Armyndharis0a1f6acd8a1e
diff --git a/dashboard/src/components/Toast.css b/dashboard/src/components/Toast.cssindex 9f8860ecb..13ed93169 100644--- a/dashboard/src/components/Toast.css+++ b/dashboard/src/components/Toast.css@@ -2,7 +2,8 @@position: fixed;bottom: 1.5rem;right: 1.5rem;- z-index: 9999;+ /* Above the media lightbox, whose portal is 9999 and comes later in the document. */+ z-index: 10000;display: flex;flex-direction: column;gap: 0.75rem;diff --git a/dashboard/src/components/Toast.css.test.ts b/dashboard/src/components/Toast.css.test.tsindex 3a2d96fc2..78899d5f2 100644--- a/dashboard/src/components/Toast.css.test.ts+++ b/dashboard/src/components/Toast.css.test.ts@@ -18,3 +18,17 @@ test('the toast close button resets the global button padding', () => {// The global button rule pads 0.6em 1.2em; on a 24px box that leaves the 16px icon no width and it collapses.assert.match(body('.toast-close'), /(?:^|;)\s*padding:\s*0\s*;/);});++// The lightbox portal comes after the toast container in the document, so at the same z-index it covers the+// toast: an error raised while a picture is open (a send that fails behind it) is dimmed under the backdrop+// and gone after its timer. The toast has to stack above the portal.+test('the toast container stacks above the media lightbox', () => {+ const zIndex = Number(/(?:^|;)\s*z-index:\s*(\d+)/.exec(body('.toast-container'))?.[1]);+ const lightbox = readFileSync(+ join(dirname(fileURLToPath(import.meta.url)), '../../node_modules/yet-another-react-lightbox/dist/styles.css'),+ 'utf8',+ );+ const portal = Number(/\.yarl__portal\{[^}]*z-index:var\(--yarl__portal_zindex,(\d+)\)/.exec(lightbox)?.[1]);+ assert.ok(zIndex > 0 && portal > 0, `unreadable z-index values: toast ${zIndex}, lightbox ${portal}`);+ assert.ok(zIndex > portal, `toast z-index ${zIndex} does not exceed the lightbox portal's ${portal}`);+});