mirror of
https://git.kescher.at/CatCatNya/catstodon.git
synced 2024-11-24 02:18:07 +01:00
Fix root modal's keyup handling (Fixes #478)
This commit is contained in:
parent
34142ab29c
commit
769a48495c
2 changed files with 3 additions and 2 deletions
|
@ -6,6 +6,7 @@ export default class ModalRoot extends React.PureComponent {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
children: PropTypes.node,
|
children: PropTypes.node,
|
||||||
onClose: PropTypes.func.isRequired,
|
onClose: PropTypes.func.isRequired,
|
||||||
|
noEsc: PropTypes.bool,
|
||||||
};
|
};
|
||||||
|
|
||||||
state = {
|
state = {
|
||||||
|
@ -16,7 +17,7 @@ export default class ModalRoot extends React.PureComponent {
|
||||||
|
|
||||||
handleKeyUp = (e) => {
|
handleKeyUp = (e) => {
|
||||||
if ((e.key === 'Escape' || e.key === 'Esc' || e.keyCode === 27)
|
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();
|
this.props.onClose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,7 @@ export default class ModalRoot extends React.PureComponent {
|
||||||
const visible = !!type;
|
const visible = !!type;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Base onClose={onClose}>
|
<Base onClose={onClose} noEsc={props.noEsc}>
|
||||||
{visible && (
|
{visible && (
|
||||||
<BundleContainer fetchComponent={MODAL_COMPONENTS[type]} loading={this.renderLoading(type)} error={this.renderError} renderDelay={200}>
|
<BundleContainer fetchComponent={MODAL_COMPONENTS[type]} loading={this.renderLoading(type)} error={this.renderError} renderDelay={200}>
|
||||||
{(SpecificComponent) => <SpecificComponent {...props} onClose={onClose} />}
|
{(SpecificComponent) => <SpecificComponent {...props} onClose={onClose} />}
|
||||||
|
|
Loading…
Reference in a new issue