From d9e6efbe794eb159f9bfaa8d27983e9d3b696982 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Tue, 26 May 2020 15:21:40 -0500 Subject: [PATCH] Revert "Merge branch 'compose_caret_to_end' into 'master'" This reverts commit 886e87799633102a15ec3193ebb0e68c0e9dd24b, reversing changes made to b6a74040316efa260f11424269098c9f8d7108c3. --- .gitignore | 1 - .../compose/components/compose_form.js | 24 +++++++------------ app/gabsocial/reducers/compose.js | 3 +-- 3 files changed, 10 insertions(+), 18 deletions(-) diff --git a/.gitignore b/.gitignore index da7dcee8d..e146e98fa 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,3 @@ /.eslintcache /.env /deploy.sh -/.vs/ diff --git a/app/gabsocial/features/compose/components/compose_form.js b/app/gabsocial/features/compose/components/compose_form.js index 7e0e18b27..acb21f5fd 100644 --- a/app/gabsocial/features/compose/components/compose_form.js +++ b/app/gabsocial/features/compose/components/compose_form.js @@ -44,7 +44,6 @@ class ComposeForm extends ImmutablePureComponent { state = { composeFocused: false, - caretPosition: 0, } static contextTypes = { @@ -87,9 +86,6 @@ class ComposeForm extends ImmutablePureComponent { handleChange = (e) => { this.props.onChange(e.target.value); - this.setState({ - caretPosition: e.target.selectionStart, - }); } handleComposeFocus = () => { @@ -184,24 +180,22 @@ class ComposeForm extends ImmutablePureComponent { // - Replying to zero or one users, places the cursor at the end of the textbox. // - Replying to more than one user, selects any usernames past the first; // this provides a convenient shortcut to drop everyone else from the conversation. - let selectionEnd, selectionStart; if (this.props.focusDate !== prevProps.focusDate) { + let selectionEnd, selectionStart; if (this.props.preselectDate !== prevProps.preselectDate) { - selectionEnd = this.props.text.length; + selectionEnd = this.props.text.length; selectionStart = this.props.text.search(/\s/) + 1; - } else if (typeof this.state.caretPosition === 'number') { - selectionStart = this.state.caretPosition; - selectionEnd = this.state.caretPosition; + } else if (typeof this.props.caretPosition === 'number') { + selectionStart = this.props.caretPosition; + selectionEnd = this.props.caretPosition; + } else { + selectionEnd = this.props.text.length; + selectionStart = selectionEnd; } + this.autosuggestTextarea.textarea.setSelectionRange(selectionStart, selectionEnd); this.autosuggestTextarea.textarea.focus(); - } else { - if (this.props.preselectDate !== this.props.focusDate) { - selectionStart = selectionEnd = this.props.text.length + 1; - this.autosuggestTextarea.textarea.setSelectionRange(selectionStart, selectionEnd); - this.autosuggestTextarea.textarea.focus(); - } } } diff --git a/app/gabsocial/reducers/compose.js b/app/gabsocial/reducers/compose.js index 39cff8eb0..49c9bf97b 100644 --- a/app/gabsocial/reducers/compose.js +++ b/app/gabsocial/reducers/compose.js @@ -237,8 +237,7 @@ export default function compose(state = initialState, action) { case COMPOSE_CHANGE: return state .set('text', action.text) - .set('idempotencyKey', uuid()) - .set('focusDate', new Date()); + .set('idempotencyKey', uuid()); case COMPOSE_COMPOSING_CHANGE: return state.set('is_composing', action.value); case COMPOSE_REPLY: