about summary refs log tree commit diff
path: root/app/javascript/mastodon/features/ui/components/modal_root.js
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2022-02-25 00:51:01 +0100
committerGitHub <noreply@github.com>2022-02-25 00:51:01 +0100
commit2cd31b31778cec3b282a44f03a03844d92a4e8cc (patch)
tree4b0d299e6ea1f064c80ab5bd62ae61ea7ade197a /app/javascript/mastodon/features/ui/components/modal_root.js
parentd4592bbfcd091c4eaef8c8f24c47d5c2ce1bacd3 (diff)
Fix reply button on media modal not giving focus to compose form (#17626)
* Avoid compose form and modal management fighting for focus

* Fix reply button on media modal footer not giving focus to compose form
Diffstat (limited to 'app/javascript/mastodon/features/ui/components/modal_root.js')
-rw-r--r--app/javascript/mastodon/features/ui/components/modal_root.js9
1 files changed, 5 insertions, 4 deletions
diff --git a/app/javascript/mastodon/features/ui/components/modal_root.js b/app/javascript/mastodon/features/ui/components/modal_root.js
index 7b14fe5ca..3fc235849 100644
--- a/app/javascript/mastodon/features/ui/components/modal_root.js
+++ b/app/javascript/mastodon/features/ui/components/modal_root.js
@@ -45,6 +45,7 @@ export default class ModalRoot extends React.PureComponent {
     type: PropTypes.string,
     props: PropTypes.object,
     onClose: PropTypes.func.isRequired,
+    ignoreFocus: PropTypes.bool,
   };
 
   state = {
@@ -79,7 +80,7 @@ export default class ModalRoot extends React.PureComponent {
     return <BundleModalError {...props} onClose={onClose} />;
   }
 
-  handleClose = () => {
+  handleClose = (ignoreFocus = false) => {
     const { onClose } = this.props;
     let message = null;
     try {
@@ -89,7 +90,7 @@ export default class ModalRoot extends React.PureComponent {
       // isn't set.
       // This would be much smoother with react-intl 3+ and `forwardRef`.
     }
-    onClose(message);
+    onClose(message, ignoreFocus);
   }
 
   setModalRef = (c) => {
@@ -97,12 +98,12 @@ export default class ModalRoot extends React.PureComponent {
   }
 
   render () {
-    const { type, props } = this.props;
+    const { type, props, ignoreFocus } = this.props;
     const { backgroundColor } = this.state;
     const visible = !!type;
 
     return (
-      <Base backgroundColor={backgroundColor} onClose={this.handleClose}>
+      <Base backgroundColor={backgroundColor} onClose={this.handleClose} ignoreFocus={ignoreFocus}>
         {visible && (
           <BundleContainer fetchComponent={MODAL_COMPONENTS[type]} loading={this.renderLoading(type)} error={this.renderError} renderDelay={200}>
             {(SpecificComponent) => <SpecificComponent {...props} onChangeBackgroundColor={this.setBackgroundColor} onClose={this.handleClose} ref={this.setModalRef} />}