mirror of
https://github.com/mastodon/mastodon.git
synced 2024-11-15 11:21:42 +00:00
Merge pull request #479 from ThibG/glitch-soc/fixes/modal-root-keyup
Fix root modal's keyup handling (Fixes #478)
This commit is contained in:
commit
bd4decb7db
|
@ -6,6 +6,7 @@ export default class ModalRoot extends React.PureComponent {
|
|||
static propTypes = {
|
||||
children: PropTypes.node,
|
||||
onClose: PropTypes.func.isRequired,
|
||||
noEsc: PropTypes.bool,
|
||||
};
|
||||
|
||||
state = {
|
||||
|
@ -16,7 +17,7 @@ export default class ModalRoot extends React.PureComponent {
|
|||
|
||||
handleKeyUp = (e) => {
|
||||
if ((e.key === 'Escape' || e.key === 'Esc' || e.keyCode === 27)
|
||||
&& !!this.props.children && !this.props.props.noEsc) {
|
||||
&& !!this.props.children && !this.props.noEsc) {
|
||||
this.props.onClose();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ export default class ModalRoot extends React.PureComponent {
|
|||
const visible = !!type;
|
||||
|
||||
return (
|
||||
<Base onClose={onClose}>
|
||||
<Base onClose={onClose} noEsc={props.noEsc}>
|
||||
{visible && (
|
||||
<BundleContainer fetchComponent={MODAL_COMPONENTS[type]} loading={this.renderLoading(type)} error={this.renderError} renderDelay={200}>
|
||||
{(SpecificComponent) => <SpecificComponent {...props} onClose={onClose} />}
|
||||
|
|
Loading…
Reference in a new issue