Close modal on escape keypress (#12428)
* tooltips 1.0.1 * tooltips 1.0.1 * close on esc * simpler
This commit is contained in:
parent
6b0505dc47
commit
bf72758c4e
2 changed files with 7 additions and 2 deletions
|
|
@ -30,8 +30,7 @@ export class Help extends Component {
|
|||
};
|
||||
};
|
||||
|
||||
toggleModal = (varShowing) => (e) => {
|
||||
e.preventDefault();
|
||||
toggleModal = (varShowing) => () => {
|
||||
this.setState((prevState) => ({
|
||||
...this.setCommonProps({
|
||||
[varShowing]: !prevState[varShowing],
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import { h } from 'preact';
|
||||
import PropTypes from 'prop-types';
|
||||
import { KeyboardShortcuts } from '../../shared/components/useKeyboardShortcuts';
|
||||
import { defaultChildrenPropTypes } from '../../common-prop-types';
|
||||
import { Button } from '@crayons';
|
||||
|
||||
|
|
@ -40,6 +41,10 @@ export const Modal = ({
|
|||
overlay,
|
||||
onClose,
|
||||
}) => {
|
||||
const shortcuts = {
|
||||
escape: onClose,
|
||||
};
|
||||
|
||||
return (
|
||||
<div
|
||||
data-testid="modal-container"
|
||||
|
|
@ -64,6 +69,7 @@ export const Modal = ({
|
|||
aria-label="Close"
|
||||
onClick={onClose}
|
||||
/>
|
||||
<KeyboardShortcuts shortcuts={shortcuts} />
|
||||
</div>
|
||||
)}
|
||||
<div className="crayons-modal__box__body">{children}</div>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue