Skip to content

Commit

Permalink
A11y: Trap focus inside open off-canvas nav
Browse files Browse the repository at this point in the history
  • Loading branch information
marcus-herrmann committed Sep 13, 2019
1 parent 10fd312 commit 303a15b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"dependencies": {
"react": "^16.9.0",
"react-dom": "^16.9.0",
"react-focus-lock": "^2.0.5",
"react-scripts": "3.1.1",
"styled-components": "^4.3.2"
},
Expand Down
7 changes: 5 additions & 2 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useOnClickOutside } from './hooks';
import { GlobalStyles } from './global';
import { theme } from './theme';
import { Burger, Menu } from './components';
import FocusLock from 'react-focus-lock';

function App() {
const [open, setOpen] = useState(false);
Expand All @@ -17,8 +18,10 @@ function App() {
<>
<GlobalStyles />
<div ref={node}>
<Burger open={open} setOpen={setOpen} aria-controls={menuId} />
<Menu open={open} setOpen={setOpen} id={menuId} />
<FocusLock disabled={!open}>
<Burger open={open} setOpen={setOpen} aria-controls={menuId} />
<Menu open={open} setOpen={setOpen} id={menuId} />
</FocusLock>
</div>
<div>
<h1>Hello. This is burger menu tutorial</h1>
Expand Down

0 comments on commit 303a15b

Please sign in to comment.