Page MenuHomePhabricator

D7825.id26491.diff
No OneTemporary

D7825.id26491.diff

diff --git a/web/chat/chat-input-text-area.react.js b/web/chat/chat-input-text-area.react.js
--- a/web/chat/chat-input-text-area.react.js
+++ b/web/chat/chat-input-text-area.react.js
@@ -10,6 +10,7 @@
+escape?: () => void,
+focus: boolean,
+currentText: string,
+ +setCurrentText: (text: string) => void,
};
type Props = {
...BaseProps,
@@ -47,6 +48,7 @@
rows="1"
placeholder="Type your message"
value={this.props.currentText}
+ onChange={this.onChangeMessageText}
onKeyDown={this.onKeyDown}
ref={this.textareaRef}
autoFocus
@@ -62,6 +64,14 @@
}
};
+ setCurrentText = (text: string) => {
+ this.props.setCurrentText(text);
+ };
+
+ onChangeMessageText = (event: SyntheticEvent<HTMLTextAreaElement>) => {
+ this.setCurrentText(event.currentTarget.value);
+ };
+
focusAndUpdateText = () => {
if (!this.props.focus) {
return;
diff --git a/web/chat/edit-message-provider.js b/web/chat/edit-message-provider.js
--- a/web/chat/edit-message-provider.js
+++ b/web/chat/edit-message-provider.js
@@ -18,6 +18,7 @@
+renderEditModal: (params: EditState) => void,
+clearEditModal: () => void,
+editState: ?EditState,
+ +setDraft: string => void,
};
const EditModalContext: React.Context<EditModalContextType> =
@@ -25,6 +26,7 @@
renderEditModal: () => {},
clearEditModal: () => {},
editState: null,
+ setDraft: () => {},
});
type Props = {
@@ -48,13 +50,27 @@
return null;
}, []);
+ const setDraft = React.useCallback(
+ (draft: ?string) => {
+ if (!editState) {
+ return;
+ }
+ setEditState({
+ ...editState,
+ editedMessageDraft: draft,
+ });
+ },
+ [editState, setEditState],
+ );
+
const value = React.useMemo(
() => ({
renderEditModal,
clearEditModal: clearEditModal,
editState,
+ setDraft,
}),
- [renderEditModal, clearEditModal, editState],
+ [renderEditModal, clearEditModal, editState, setDraft],
);
let modalOverlay;
diff --git a/web/chat/edit-text-message.react.js b/web/chat/edit-text-message.react.js
--- a/web/chat/edit-text-message.react.js
+++ b/web/chat/edit-text-message.react.js
@@ -26,6 +26,7 @@
...BaseProps,
+editState: ?EditState,
+clearEditModal: () => void,
+ +setDraft: string => void,
};
class EditTextMessage extends React.PureComponent<Props> {
myRef: { current: null | HTMLDivElement };
@@ -71,6 +72,7 @@
<ChatInputTextArea
focus={!this.props.background}
currentText={editedMessageDraft}
+ setCurrentText={this.props.setDraft}
/>
</div>
<div className={css.bottomRow}>
@@ -93,12 +95,13 @@
const ConnectedEditTextMessage: React.ComponentType<BaseProps> =
React.memo<BaseProps>(function ConnectedEditTextMessage(props) {
- const { editState, clearEditModal } = useEditModalContext();
+ const { editState, clearEditModal, setDraft } = useEditModalContext();
return (
<EditTextMessage
{...props}
editState={editState}
clearEditModal={clearEditModal}
+ setDraft={setDraft}
/>
);
});

File Metadata

Mime Type
text/plain
Expires
Sun, Dec 1, 2:00 AM (21 h, 14 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2603257
Default Alt Text
D7825.id26491.diff (3 KB)

Event Timeline