trap focus
This commit is contained in:
@@ -9,9 +9,20 @@ import { NAV_ITEMS } from '../nav';
|
|||||||
|
|
||||||
const SIDEBAR_WIDTH = 144;
|
const SIDEBAR_WIDTH = 144;
|
||||||
|
|
||||||
|
const FOCUSABLE =
|
||||||
|
'a, button, input, textarea, select, [role="button"], [role="menuitem"], [tabindex]:not([tabindex="-1"]), [contenteditable="true"]';
|
||||||
|
|
||||||
|
function preserveFocusOnBackground(e) {
|
||||||
|
if (e.target.closest(FOCUSABLE)) return;
|
||||||
|
e.preventDefault();
|
||||||
|
}
|
||||||
|
|
||||||
export default function AppShell() {
|
export default function AppShell() {
|
||||||
return (
|
return (
|
||||||
<Box sx={{ display: 'flex', minHeight: '100vh', bgcolor: 'background.default' }}>
|
<Box
|
||||||
|
onMouseDown={preserveFocusOnBackground}
|
||||||
|
sx={{ display: 'flex', minHeight: '100vh', bgcolor: 'background.default' }}
|
||||||
|
>
|
||||||
<Box
|
<Box
|
||||||
component="nav"
|
component="nav"
|
||||||
sx={(theme) => ({
|
sx={(theme) => ({
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ export default function PageLayout({ title, subNav, basePath, children }) {
|
|||||||
end={!segment}
|
end={!segment}
|
||||||
aria-label={label}
|
aria-label={label}
|
||||||
disableRipple
|
disableRipple
|
||||||
|
onMouseDown={(e) => e.preventDefault()}
|
||||||
sx={(theme) => ({
|
sx={(theme) => ({
|
||||||
width: 80,
|
width: 80,
|
||||||
height: 80,
|
height: 80,
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ export default function UserMenu() {
|
|||||||
<Box sx={{ px: 1.5, py: 1.5, alignSelf: 'flex-start' }}>
|
<Box sx={{ px: 1.5, py: 1.5, alignSelf: 'flex-start' }}>
|
||||||
<IconButton
|
<IconButton
|
||||||
onClick={(e) => setAnchorEl(e.currentTarget)}
|
onClick={(e) => setAnchorEl(e.currentTarget)}
|
||||||
|
onMouseDown={(e) => e.preventDefault()}
|
||||||
sx={{ p: 0, width: 32, height: 32, borderRadius: '50%' }}
|
sx={{ p: 0, width: 32, height: 32, borderRadius: '50%' }}
|
||||||
>
|
>
|
||||||
<Avatar src={user?.picture} alt={user?.email} sx={{ width: 32, height: 32 }}>
|
<Avatar src={user?.picture} alt={user?.email} sx={{ width: 32, height: 32 }}>
|
||||||
|
|||||||
Reference in New Issue
Block a user