[Dialog] Pressing escape key inside of dialog when footer exists in Safari scrolls to the last focusable element on the page
See original GitHub issue🐛 Bug report
Test setup
- Use Safari browser
- Reach dialog with text input inside of it
- <footer> tag exists on page
Current Behavior
Right now when you open the dialog (before you make any user action on the dialog) press the escape key and it jumps to the bottom of the screen
Expected behavior
I feel as though this is an undesirable effect and should react the same as when a footer doesn’t exist. This may be due to safari behaviour
Reproducible example
Could not use code sandbox as it didn’t show the issue since the virtual browser is not safari based. Using this simple reproducible code in any scenario should be sufficient as long as you open the page in safari.
import React from "react";
import Dialog from "@reach/dialog";
export default function DialogExample() {
const [showDialog, setShowDialog] = React.useState(false);
const open = () => setShowDialog(true);
const close = () => setShowDialog(false);
return (
<div>
<button onClick={open}>Open Dialog</button>
<Dialog isOpen={showDialog} onDismiss={close}>
<input />
</Dialog>
<div style={{ height: "200vh" }}></div>
<footer>footer</footer>
</div>
);
}
Suggested solution(s)
Maybe it’s possible to block escape key default event?
Additional context
N/A
Your environment
Software | Name(s) | Version |
---|---|---|
Reach Package | @reach/dialog | 0.13.2 |
React | 17.0.1 | |
Browser | safari | 14.0.3 |
Assistive tech | ||
Node | v12.18.4 | |
npm/yarn | yarn | 1.22.10 |
Operating System | MacOS Big Sur | 11.2 |
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:11 (6 by maintainers)
Top Results From Across the Web
A CSS Approach to Trap Focus Inside of an Element
To summarize, when inside a dialog, pressing Tab or Shift+Tab should cycle the focus within the dialog only—amongst the focusable elements ...
Read more >Select2 doesn't work when embedded in a bootstrap modal
Ok, I've got it to work. change <div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> ...
Read more >angular material dialog disable click outside - You.com
Initially, the dialog will have the configuration option disableClose set as true . This ensures that the esc keypress, as well as clicking...
Read more >Safari Technology Preview Release Notes - Apple Developer
Updated shadow DOM and dialog element focusing to the latest spec ... repaint on a shadow host when the focus moves from outside...
Read more >Ext.Dialog | Ext JS 6.5.0 - Sencha Documentation
With Ext.Dialog , both the ESC key and close tool handler call the close ... inside this Component, or a reference to an...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hello there, my very own project suffering from this issue. The issue appears when
focus lock
was opened with no prioractiveElement
, in this case it returns a focus to the body, which causes this effect.Reproducible on Desktop and Mobile Safari. Strangely working fine in Browser Stack environment.
Pinned tab and will take a look