1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-16 20:24:01 +02:00

fix <Node> shouldComponentUpdate for blurring

This commit is contained in:
Ian Storm Taylor
2016-09-10 19:27:07 -07:00
parent f51ac69bdf
commit b8992c100a

View File

@@ -95,10 +95,26 @@ class Node extends React.Component {
return true 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 <Leaf> components.
if ( if (
props.node != this.props.node || props.state.isFocused &&
(props.state.isFocused && props.state.selection.hasEdgeIn(props.node)) 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 return true
} }