Page MenuHomePhabricator

D3797.diff
No OneTemporary

D3797.diff

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 (
<Modal onClose={modalContext.clearModal} name="Invalid thread">

File Metadata

Mime Type
text/plain
Expires
Wed, Nov 27, 11:32 PM (21 h, 50 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2592083
Default Alt Text
D3797.diff (1 KB)

Event Timeline