From d530a9401f5fba7c2491d3ddf1641079d3619838 Mon Sep 17 00:00:00 2001 From: Ali Abbas Malik Date: Tue, 8 Jun 2021 08:53:44 -0700 Subject: [PATCH] [IS-3218] Fixed cursor issue on edit comment box --- .../home/report/ReportActionItemMessageEdit.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/pages/home/report/ReportActionItemMessageEdit.js b/src/pages/home/report/ReportActionItemMessageEdit.js index 24598414f083..798fc3ad5d0c 100644 --- a/src/pages/home/report/ReportActionItemMessageEdit.js +++ b/src/pages/home/report/ReportActionItemMessageEdit.js @@ -36,12 +36,26 @@ class ReportActionItemMessageEdit extends React.Component { this.debouncedSaveDraft = _.debounce(this.debouncedSaveDraft.bind(this), 1000, true); this.publishDraft = this.publishDraft.bind(this); this.triggerSaveOrCancel = this.triggerSaveOrCancel.bind(this); + this.onSelectionChange = this.onSelectionChange.bind(this); this.state = { draft: this.props.draftMessage, + selection: { + start: this.props.draftMessage.length, + end: this.props.draftMessage.length, + }, }; } + /** + * Update Selection on change cursor position. + * + * @param {Event} e + */ + onSelectionChange(e) { + this.setState({selection: e.nativeEvent.selection}); + } + /** * Update the value of the draft in Onyx * @@ -109,6 +123,8 @@ class ReportActionItemMessageEdit extends React.Component { toggleReportActionComposeView(false); }} autoFocus + selection={this.state.selection} + onSelectionChange={this.onSelectionChange} />