diff --git a/web/modals/threads/thread-settings-modal.react.js b/web/modals/threads/thread-settings-modal.react.js --- a/web/modals/threads/thread-settings-modal.react.js +++ b/web/modals/threads/thread-settings-modal.react.js @@ -105,6 +105,7 @@ +deleteThreadAction: () => Promise<LeaveThreadPayload>, +onDelete: (event: SyntheticEvent<HTMLElement>) => void, +changeThreadSettingsAction: () => Promise<ChangeThreadSettingsPayload>, + +onSubmit: (event: SyntheticEvent<HTMLElement>) => void, }; class ThreadSettingsModal extends React.PureComponent<Props> { nameInput: ?HTMLInputElement; @@ -203,7 +204,7 @@ buttons = ( <Button type="submit" - onClick={this.onSubmit} + onClick={this.props.onSubmit} disabled={inputDisabled || !this.props.changeQueued} className={css.save_button} > @@ -284,14 +285,6 @@ accountPasswordInputRef = (accountPasswordInput: ?HTMLInputElement) => { this.accountPasswordInput = accountPasswordInput; }; - - onSubmit = (event: SyntheticEvent<HTMLElement>) => { - event.preventDefault(); - this.props.dispatchActionPromise( - changeThreadSettingsActionTypes, - this.props.changeThreadSettingsAction(), - ); - }; } const deleteThreadLoadingStatusSelector = createLoadingStatusSelector( @@ -474,6 +467,17 @@ } }, [callChangeThreadSettings, modalContext, queuedChanges, threadInfo]); + const onSubmit = React.useCallback( + (event: SyntheticEvent<HTMLElement>) => { + event.preventDefault(); + dispatchActionPromise( + changeThreadSettingsActionTypes, + changeThreadSettingsAction(), + ); + }, + [changeThreadSettingsAction, dispatchActionPromise], + ); + if (!threadInfo) { return ( <Modal onClose={modalContext.clearModal} name="Invalid thread"> @@ -515,6 +519,7 @@ deleteThreadAction={deleteThreadAction} onDelete={onDelete} changeThreadSettingsAction={changeThreadSettingsAction} + onSubmit={onSubmit} /> ); },