From a7d2692a71d8546fcba4e580a48212c61ac4c21f Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Mon, 28 Sep 2020 23:54:47 -0500 Subject: [PATCH] AutosuggestTextarea: shouldComponentUpdate fixes --- app/soapbox/components/autosuggest_textarea.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/soapbox/components/autosuggest_textarea.js b/app/soapbox/components/autosuggest_textarea.js index f3274c6a2..baaf3e8b0 100644 --- a/app/soapbox/components/autosuggest_textarea.js +++ b/app/soapbox/components/autosuggest_textarea.js @@ -160,9 +160,12 @@ export default class AutosuggestTextarea extends ImmutablePureComponent { } shouldComponentUpdate(nextProps, nextState) { - // Skip updating when lastToken changes so the cursor doesn't jump around - // due to re-rendering unnecessarily - if (this.state.lastToken !== nextState.lastToken) { + // Skip updating when only the lastToken changes so the + // cursor doesn't jump around due to re-rendering unnecessarily + const lastTokenUpdated = this.state.lastToken !== nextState.lastToken; + const valueUpdated = this.props.value !== nextProps.value; + + if (lastTokenUpdated && !valueUpdated) { return false; } else { return super.shouldComponentUpdate(nextProps, nextState);