[Glitch] Fix reply button on media modal not giving focus to compose form

Port 2cd31b3177 to glitch-soc

Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
Claire
2022-02-25 00:51:01 +01:00
parent 2e2b8a9a40
commit 8e04ba87b7
7 changed files with 51 additions and 20 deletions

View File

@ -55,6 +55,7 @@ export default class ModalRoot extends React.PureComponent {
type: PropTypes.string,
props: PropTypes.object,
onClose: PropTypes.func.isRequired,
ignoreFocus: PropTypes.bool,
};
state = {
@ -85,7 +86,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 {
@ -95,7 +96,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) => {
@ -103,12 +104,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} noEsc={props ? props.noEsc : false}>
<Base backgroundColor={backgroundColor} onClose={this.handleClose} noEsc={props ? props.noEsc : false} 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} />}