mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-16 12:14:14 +02:00
fix <Node> shouldComponentUpdate for blurring
This commit is contained in:
@@ -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 <Leaf> 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
|
||||
}
|
||||
|
Reference in New Issue
Block a user