issue #89: add event listener for escape key #90
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Re: @mwarin's suggestion in PR #88
I did some testing and found an additional bug: my original fix returned the focus to the GET HELP link when you use the CLOSE button on the modal, but the
ESC
key returned the focus back to the body element.This event listener (with a few
.focus()
methods thrown in for fallback/good measure) picks up onESC
keys and invokes thehide()
function (which sets the focus back to GET HELP).This closes issue #89.
To test: head over to dev-3 and tab through the nav menu to GET HELP. Select with ENTER and tab down to Ask a Question. Hit ENTER again to open the modal. Hit ESC to close modal. Focus should be returned to GET HELP in navbar. If you tab through some fields in the form, you have to hit ESC to exit the form field, then ESC again should close the modal and return focus to GET HELP.