Merge branch 'compose-emoji-typing' into 'develop'
AutosuggestTextarea: shouldComponentUpdate fixes See merge request soapbox-pub/soapbox-fe!278
This commit is contained in:
commit
ca0d39ef88
1 changed files with 6 additions and 3 deletions
|
@ -160,9 +160,12 @@ export default class AutosuggestTextarea extends ImmutablePureComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
shouldComponentUpdate(nextProps, nextState) {
|
shouldComponentUpdate(nextProps, nextState) {
|
||||||
// Skip updating when lastToken changes so the cursor doesn't jump around
|
// Skip updating when only the lastToken changes so the
|
||||||
// due to re-rendering unnecessarily
|
// cursor doesn't jump around due to re-rendering unnecessarily
|
||||||
if (this.state.lastToken !== nextState.lastToken) {
|
const lastTokenUpdated = this.state.lastToken !== nextState.lastToken;
|
||||||
|
const valueUpdated = this.props.value !== nextProps.value;
|
||||||
|
|
||||||
|
if (lastTokenUpdated && !valueUpdated) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
return super.shouldComponentUpdate(nextProps, nextState);
|
return super.shouldComponentUpdate(nextProps, nextState);
|
||||||
|
|
Loading…
Reference in a new issue