Skip to content

Commit

Permalink
fix(portable-text-editor): fix missing props.value updates
Browse files Browse the repository at this point in the history
  • Loading branch information
skogsmaskin committed Aug 17, 2022
1 parent 5abfe3a commit 6a5c972
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -255,12 +255,15 @@ export class PortableTextEditor extends React.Component<
this.slateInstance.maxBlocks = this.maxBlocks
}

// Update the value if we are not subscribing to patches,
if (!this.props.incomingPatches$ && this.state.currentValue !== this.props.value) {
// Update the value directly from props if we are not subscribing to patches or in readOnly mode.
if (
(!this.props.incomingPatches$ || this.readOnly) &&
this.state.currentValue !== this.props.value
) {
this.syncValue()
}
// Initial value sync when subscribing to patches
if (this.props.incomingPatches$ && this.state.currentValue === null && this.props.value) {
// Initial value sync
if (this.state.currentValue === null && this.props.value) {
this.syncValue()
}
}
Expand Down

0 comments on commit 6a5c972

Please sign in to comment.