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 @@ -114,30 +114,6 @@ super(props); } - componentDidMount() { - invariant(this.nameInput, 'nameInput ref unset'); - this.nameInput.focus(); - } - - componentDidUpdate(prevProps: Props) { - if (this.props.currentTabType !== 'delete') { - return; - } - - const permissionForDeleteTab = this.props.hasPermissionForTab( - this.props.threadInfo, - 'delete', - ); - const prevPermissionForDeleteTab = this.props.hasPermissionForTab( - prevProps.threadInfo, - 'delete', - ); - - if (!permissionForDeleteTab && prevPermissionForDeleteTab) { - this.setTab('general'); - } - } - possiblyChangedValue(key: string) { const valueChanged = this.props.queuedChanges[key] !== null && @@ -482,6 +458,19 @@ [changeThreadSettingsAction, dispatchActionPromise], ); + React.useEffect(() => { + // TODO: nameInput.focus() + // (once ref is moved up to functional component) + + if ( + threadInfo && + currentTabType !== 'general' && + !hasPermissionForTab(threadInfo, currentTabType) + ) { + setCurrentTabType('general'); + } + }, [currentTabType, hasPermissionForTab, threadInfo]); + if (!threadInfo) { return (