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

[tree] escape key dismisses any info modal #1485

Merged
merged 1 commit into from
Mar 17, 2022
Merged

Conversation

jameshadfield
Copy link
Member

This implements what we think is an intuitive UI, and also helps with
the bug described in #1243 where removing/disabling a strain-filter
results in the tree visualisation falling out-of-sync with the modal.

See #1479 for context.

Closes #1479

@@ -41,6 +41,12 @@ class Tree extends React.Component {
root: [0, 0]
}));
};
/* pressing the escape key should dismiss an info modal (if one exists) */
this.handlekeydownEvent = (event) => {
if (event.keyCode===27 && this.state.selectedNode) { // key 27 is esc
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, keyCode has been marked as deprecated.

The alternative is to use key, which is equal to "Escape" or "Esc" in older browsers (see key values):

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did not know, thanks Jover! Fixed & force-pushed.

This implements what we think is an intuitive UI, and also helps with
the bug described in #1243 where removing/disabling a strain-filter
results in the tree visualisation falling out-of-sync with the modal.

Note that `event.key` may not be implemented in all browsers, however
this functionality is a nicety rather than a must-have, so this is
tolerable. Thanks to @joverlee521 for suggesting to use this instead of
`event.keyCode` during PR review.

See #1479 for context.

Closes #1479
@jameshadfield jameshadfield temporarily deployed to auspice-feat-escape-mod-7v44bx March 17, 2022 00:10 Inactive
@jameshadfield jameshadfield merged commit 588bd6a into master Mar 17, 2022
@jameshadfield jameshadfield deleted the feat/escape-modal branch March 17, 2022 20:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

ENH: Make Esc dismiss sample details popup
3 participants