From b8992c100a3252a9ab088d0502042e29ef0be75c Mon Sep 17 00:00:00 2001 From: Ian Storm Taylor Date: Sat, 10 Sep 2016 19:27:07 -0700 Subject: [PATCH] fix shouldComponentUpdate for blurring --- lib/components/node.js | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/lib/components/node.js b/lib/components/node.js index 7b29e7a68..3a91463ec 100644 --- a/lib/components/node.js +++ b/lib/components/node.js @@ -95,10 +95,26 @@ class Node extends React.Component { return true } - // Otherwise, perform a peformant update check by default. + // If the node has changed, update. + if (props.node != this.props.node) { + return true + } + + // If the selection is focused and is inside the node, we need to update so + // that the selection will be set by one of the components. if ( - props.node != this.props.node || - (props.state.isFocused && props.state.selection.hasEdgeIn(props.node)) + props.state.isFocused && + props.state.selection.hasEdgeIn(props.node) + ) { + return true + } + + // If the selection is blurred but was previously focused inside the node, + // we need to update to ensure the selection gets updated by re-rendering. + if ( + props.state.isBlurred && + this.props.state.isFocused && + this.props.state.selection.hasEdgeIn(props.node) ) { return true }