Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds information on escaping focus traps in Readme #181

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,20 @@ with valid JSX elements.
This component renders the editor that displays the code. It is a wrapper around [`react-simple-code-editor`](https://github.com/satya164/react-simple-code-editor) and the code highlighted using [`prism-react-renderer`](https://github.com/FormidableLabs/prism-react-renderer).


`LiveEditor` can create a focus trap on the page for users using keyboard navigation. `react-simple-code-editor` provides a focus escape hatch via the `escape` key, allowing the user to continue tab navigating. More custom solutions may be passed down via the `onKeyDown` property with an `event.preventDefault` included in the handler. For example if you would like to exit the focus state when pressing the tab key inside the editor:

```js
<LiveEditor onKeyDown={(e) => {
if (e.keyCode === 9 ) { // tab key
e.preventDefault()
e.target.blur()
}
}}
/>

```


### &lt;LiveError /&gt;

This component renders any error that occur while executing the code, or transpiling it.
Expand Down