Skip to content

Commit

Permalink
Add [inert] attribute to #root when in modal dialog
Browse files Browse the repository at this point in the history
Fixes #2618
  • Loading branch information
CarolineDenis committed Mar 28, 2023
1 parent ec0ad44 commit b5959ee
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ export function Contexts({
header={commonText.loading()}
isOpen={isLoading}
onClose={undefined}
modal={false}
>
{loadingBar}
</Dialog>
Expand Down
12 changes: 12 additions & 0 deletions specifyweb/frontend/js_src/lib/components/Molecules/Dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,18 @@ export function Dialog({
}): JSX.Element {
const id = useId('modal');

const root = document.getElementById('root');
React.useEffect(() => {
if (modal === true) {
root?.setAttribute('inert', 'true');
} else {
root?.removeAttribute('inert');
}
return () => {
root?.removeAttribute('inert');
};
}, [modal]);

const [modifyTitle] = usePref('general', 'dialog', 'updatePageTitle');
useTitle(modal && isOpen && modifyTitle ? header : undefined);

Expand Down

0 comments on commit b5959ee

Please sign in to comment.