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 @@ -95,6 +95,7 @@ +setQueuedChanges: SetState, +namePlaceholder: string, +changeQueued: boolean, + +onChangeName: (event: SyntheticEvent) => void, }; class ThreadSettingsModal extends React.PureComponent { nameInput: ?HTMLInputElement; @@ -166,7 +167,7 @@ ) => { - const target = event.currentTarget; - const newValue = - target.value !== this.props.threadInfo.name ? target.value : undefined; - this.props.setQueuedChanges( - Object.freeze({ - ...this.props.queuedChanges, - name: firstLine(newValue), - }), - ); - }; - onChangeDescription = (event: SyntheticEvent) => { const target = event.currentTarget; const newValue = @@ -448,6 +437,21 @@ [queuedChanges], ); + const onChangeName = React.useCallback( + (event: SyntheticEvent) => { + const target = event.currentTarget; + setQueuedChanges( + Object.freeze({ + ...queuedChanges, + name: firstLine( + target.value !== threadInfo?.name ? target.value : undefined, + ), + }), + ); + }, + [queuedChanges, threadInfo?.name], + ); + if (!threadInfo) { return ( @@ -479,6 +483,7 @@ setQueuedChanges={setQueuedChanges} namePlaceholder={namePlaceholder} changeQueued={changeQueued} + onChangeName={onChangeName} /> ); },