Browse Source

Fix root modal's keyup handling (Fixes #478)

closed-social-glitch-2
Thibaut Girka 6 years ago
parent
commit
769a48495c
2 changed files with 3 additions and 2 deletions
  1. +2
    -1
      app/javascript/flavours/glitch/components/modal_root.js
  2. +1
    -1
      app/javascript/flavours/glitch/features/ui/components/modal_root.js

+ 2
- 1
app/javascript/flavours/glitch/components/modal_root.js View File

@ -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();
}
}

+ 1
- 1
app/javascript/flavours/glitch/features/ui/components/modal_root.js View File

@ -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…
Cancel
Save