Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/core-data/src/utils/crdt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ export function applyPostChangesToCRDTDoc(
// Draft" template title is not synced.
if (
key === 'title' &&
! currentValue &&
! currentValue?.toString() &&
'Auto Draft' === rawValue
) {
rawValue = '';
Expand Down
22 changes: 22 additions & 0 deletions packages/core-data/src/utils/test/crdt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,28 @@ describe( 'crdt', () => {
expect( title?.toString() ).toBe( '' );
} );

it( 'skips "Auto Draft" template title when current value is empty Y.Text', () => {
// First set an empty title (simulates a prior sync that cleared it).
applyPostChangesToCRDTDoc(
doc,
{ title: '' } as PostChanges,
mockPostType
);

const title = map.get( 'title' );
expect( title ).toBeInstanceOf( Y.Text );
expect( title?.toString() ).toBe( '' );

// Now sync "Auto Draft" — should still be suppressed.
applyPostChangesToCRDTDoc(
doc,
{ title: 'Auto Draft' } as PostChanges,
mockPostType
);

expect( map.get( 'title' )?.toString() ).toBe( '' );
} );

it( 'handles excerpt with RenderedText format', () => {
const changes = {
excerpt: {
Expand Down
Loading