From 7bb32d899642096b44b667f774cae4c0179c818e Mon Sep 17 00:00:00 2001 From: tugbadogan Date: Tue, 23 Mar 2021 13:34:03 +0000 Subject: [PATCH 1/2] Fixed moving cursor to end problem except IOUAmountPage --- src/components/TextInputFocusable/index.js | 8 +++++++- src/pages/iou/steps/IOUAmountPage.js | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/components/TextInputFocusable/index.js b/src/components/TextInputFocusable/index.js index f89ea10a211e..51ef1899b5e3 100644 --- a/src/components/TextInputFocusable/index.js +++ b/src/components/TextInputFocusable/index.js @@ -37,6 +37,9 @@ const propTypes = { // Whether or not this TextInput is disabled. isDisabled: PropTypes.bool, + + // Whether or not force move cursor to end all the time + forceMoveCursorToEnd: PropTypes.bool, }; const defaultProps = { @@ -49,6 +52,7 @@ const defaultProps = { onDragLeave: () => {}, onDrop: () => {}, isDisabled: false, + forceMoveCursorToEnd: false, }; const IMAGE_EXTENSIONS = { @@ -110,7 +114,9 @@ class TextInputFocusable extends React.Component { } if (prevProps.defaultValue !== this.props.defaultValue) { this.updateNumberOfLines(); - this.moveCursorToEnd(); + if (this.props.forceMoveCursorToEnd) { + this.moveCursorToEnd(); + } } } diff --git a/src/pages/iou/steps/IOUAmountPage.js b/src/pages/iou/steps/IOUAmountPage.js index 4d0c2e99d67e..9b52a1535c3d 100644 --- a/src/pages/iou/steps/IOUAmountPage.js +++ b/src/pages/iou/steps/IOUAmountPage.js @@ -94,6 +94,7 @@ class IOUAmountPage extends React.Component { ref={el => this.textInput = el} defaultValue={this.props.amount} textAlign="left" + forceMoveCursorToEnd /> Date: Wed, 24 Mar 2021 15:41:42 +0000 Subject: [PATCH 2/2] Removing move cursor to end feature from TextInputFocusable --- src/components/TextInputFocusable/index.js | 20 -------------------- src/pages/iou/steps/IOUAmountPage.js | 1 - 2 files changed, 21 deletions(-) diff --git a/src/components/TextInputFocusable/index.js b/src/components/TextInputFocusable/index.js index 51ef1899b5e3..bef213b31d27 100644 --- a/src/components/TextInputFocusable/index.js +++ b/src/components/TextInputFocusable/index.js @@ -37,9 +37,6 @@ const propTypes = { // Whether or not this TextInput is disabled. isDisabled: PropTypes.bool, - - // Whether or not force move cursor to end all the time - forceMoveCursorToEnd: PropTypes.bool, }; const defaultProps = { @@ -52,7 +49,6 @@ const defaultProps = { onDragLeave: () => {}, onDrop: () => {}, isDisabled: false, - forceMoveCursorToEnd: false, }; const IMAGE_EXTENSIONS = { @@ -114,9 +110,6 @@ class TextInputFocusable extends React.Component { } if (prevProps.defaultValue !== this.props.defaultValue) { this.updateNumberOfLines(); - if (this.props.forceMoveCursorToEnd) { - this.moveCursorToEnd(); - } } } @@ -205,19 +198,6 @@ class TextInputFocusable extends React.Component { }); } - /** - * Move cursor to end by setting start and end - * to length of the input value. - */ - moveCursorToEnd() { - this.setState({ - selection: { - start: this.props.defaultValue.length, - end: this.props.defaultValue.length, - }, - }); - } - focusInput() { this.textInput.focus(); } diff --git a/src/pages/iou/steps/IOUAmountPage.js b/src/pages/iou/steps/IOUAmountPage.js index 9b52a1535c3d..4d0c2e99d67e 100644 --- a/src/pages/iou/steps/IOUAmountPage.js +++ b/src/pages/iou/steps/IOUAmountPage.js @@ -94,7 +94,6 @@ class IOUAmountPage extends React.Component { ref={el => this.textInput = el} defaultValue={this.props.amount} textAlign="left" - forceMoveCursorToEnd />