From bdd238de0e3c2797ccbe9db5957a3b5dbafc79ba Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Sun, 19 May 2024 16:26:15 +0800 Subject: [PATCH] Test using inert to control text searchability --- src/components/modal.jsx | 18 ++++++++++++++++++ src/pages/status.jsx | 12 ++++++++++++ 2 files changed, 30 insertions(+) diff --git a/src/components/modal.jsx b/src/components/modal.jsx index f1aaaf0e..0587b3ce 100644 --- a/src/components/modal.jsx +++ b/src/components/modal.jsx @@ -41,6 +41,24 @@ function Modal({ children, onClose, onClick, class: className }) { ); useCloseWatcher(onClose, [onClose]); + useEffect(() => { + const $deckContainers = document.querySelectorAll('.deck-container'); + if (children) { + $deckContainers.forEach(($deckContainer) => { + $deckContainer.setAttribute('inert', ''); + }); + } else { + $deckContainers.forEach(($deckContainer) => { + $deckContainer.removeAttribute('inert'); + }); + } + return () => { + $deckContainers.forEach(($deckContainer) => { + $deckContainer.removeAttribute('inert'); + }); + }; + }, [children]); + const Modal = (
{ diff --git a/src/pages/status.jsx b/src/pages/status.jsx index 50c3b305..01585a54 100644 --- a/src/pages/status.jsx +++ b/src/pages/status.jsx @@ -153,6 +153,18 @@ function StatusPage(params) { return () => clearTimeout(timer); }, [showMediaOnly]); + useEffect(() => { + const $deckContainers = document.querySelectorAll('.deck-container'); + $deckContainers.forEach(($deckContainer) => { + $deckContainer.setAttribute('inert', ''); + }); + return () => { + $deckContainers.forEach(($deckContainer) => { + $deckContainer.removeAttribute('inert'); + }); + }; + }, []); + return (
{showMedia ? (