Page MenuHomePhabricator

D3797.id11683.diff
No OneTemporary

D3797.id11683.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
@@ -115,30 +115,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.props.setTab('general');
- }
- }
-
possiblyChangedValue(key: string) {
const valueChanged =
this.props.queuedChanges[key] !== null &&
@@ -478,6 +454,19 @@
[changeThreadSettingsAction, dispatchActionPromise],
);
+ React.useEffect(() => {
+ // TODO: nameInput.focus()
+ // (once ref is moved up to functional component)
+
+ if (
+ threadInfo &&
+ currentTabType === 'delete' &&
+ !hasPermissionForTab(threadInfo, 'delete')
+ ) {
+ setCurrentTabType('general');
+ }
+ }, [currentTabType, hasPermissionForTab, threadInfo]);
+
if (!threadInfo) {
return (
<Modal onClose={modalContext.clearModal} name="Invalid thread">

File Metadata

Mime Type
text/plain
Expires
Fri, Sep 20, 8:18 AM (18 h, 3 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2143844
Default Alt Text
D3797.id11683.diff (1 KB)

Event Timeline