Browse Source

Prevent doodle from closing on outside click (#2047)

Adds a new property to the dispatch, which when set to true, replaces the onClose handler with a no-op, preventing the modal from closing.

Signed-off-by: Plastikmensch <plastikmensch@users.noreply.github.com>

Signed-off-by: Plastikmensch <plastikmensch@users.noreply.github.com>
closed-social-glitch-2
Plastikmensch 1 year ago
committed by GitHub
parent
commit
910d2d9f6b
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions
  1. +1
    -1
      app/javascript/flavours/glitch/features/compose/containers/options_container.js
  2. +4
    -1
      app/javascript/flavours/glitch/features/ui/components/modal_root.js

+ 1
- 1
app/javascript/flavours/glitch/features/compose/containers/options_container.js View File

@ -46,7 +46,7 @@ const mapDispatchToProps = (dispatch) => ({
},
onDoodleOpen() {
dispatch(openModal('DOODLE', { noEsc: true }));
dispatch(openModal('DOODLE', { noEsc: true, noClose: true }));
},
});

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

@ -116,13 +116,16 @@ export default class ModalRoot extends React.PureComponent {
this._modal = c;
}
// prevent closing of modal when clicking the overlay
noop = () => {}
render () {
const { type, props, ignoreFocus } = this.props;
const { backgroundColor } = this.state;
const visible = !!type;
return (
<Base backgroundColor={backgroundColor} onClose={this.handleClose} noEsc={props ? props.noEsc : false} ignoreFocus={ignoreFocus}>
<Base backgroundColor={backgroundColor} onClose={props && props.noClose ? this.noop : this.handleClose} noEsc={props ? props.noEsc : false} ignoreFocus={ignoreFocus}>
{visible && (
<>
<BundleContainer fetchComponent={MODAL_COMPONENTS[type]} loading={this.renderLoading(type)} error={this.renderError} renderDelay={200}>

Loading…
Cancel
Save