-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Modal should capture all key presses while being open #1732
Comments
@levithomason commented on this before there and there. I agree with him, You can simply remove focus from |
https://codepen.io/anon/pen/JJdbjm Add a button <Button id='my-button' color='green' inverted onClick={this.closeModal.bind(this)}>
<Icon name='checkmark' /> Yes
</Button> After the state change to this.setState({
open: true,
}, () => {
// after modal opens, focus the modal button
const $button = document.querySelector('#my-button')
if ($button) $button.focus()
}) |
@levithomason Isn't that a rather dirty solution having to use Also, for some reason the |
Steps
I have a login form with username and password fields and a submit button. When the form is submitted, an API call is made and if the response is not successful a
Modal
is displayed notifying the user.The problem is - while the modal is being displayed, the cursor is still in the username/password field and if I press Enter hoping to close the modal it resubmits the form even though the modal is covering the whole page. I've not found an easy way to automatically focus on the button in the modal.
Expected Result
Modal/dimmer to capture key presses and act as a layer covering the whole page. At least give us an option which modal action to activate (default to) on open.
Actual Result
Dimmed modal is acting as if it's "transparent" even though it's covering the whole page and not capturing focus.
Version
0.68.5
Testcase
https://codepen.io/anon/pen/wewbjX
Open console, focus on the username field and press Enter multiple times. Watch form submission messages being logged on every Enter press.
Note
The same isssue is happening with the
Form
element ifloading
is set totrue
. One can keep submitting the form even though it's covered by the loading overlay.Probably related to #1341.
The text was updated successfully, but these errors were encountered: