Skip to content

Commit

Permalink
fix: Prevent unnecessary content changes clearing redo actions
Browse files Browse the repository at this point in the history
In this context, `this.value` is not a string but a instance of
`RichTextData`. Therefore, comparing the two values results in
unexpected inequality, triggering an update of the block's
`attributes.content` toggling it from a `ReactTextData` instance to a
string. This toggle results in the undo manager tracking the change as
a new line of editor history, clearing out any pending redo actions.

The `RichTextData` type was introduced in #43204. Invoking `toString`
may not be the best long-term solution to this problem. Refactoring the
rich text implementation to appropriately leverage `RichTextData` and
(potentially) treat `value` and `record` values different and storing
them separately may be necessary.
  • Loading branch information
dcalhoun committed Dec 13, 2023
1 parent fdea164 commit 05df053
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ export class RichText extends Component {
);

this.debounceCreateUndoLevel();
const refresh = this.value !== contentWithoutRootTag;
const refresh = this.value.toString() !== contentWithoutRootTag;
this.value = contentWithoutRootTag;

// We don't want to refresh if our goal is just to create a record.
Expand Down

0 comments on commit 05df053

Please sign in to comment.