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
5 changes: 4 additions & 1 deletion packages/sync/src/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,10 @@ export function createSyncManager( debug = false ): SyncManager {
// via its pre-persist hook.)
targetDoc.transact( () => {
applyChangesToCRDTDoc( targetDoc, record );
handlers.saveRecord();

if ( 'auto-draft' !== record.status ) {
handlers.saveRecord();
}
}, LOCAL_SYNC_MANAGER_ORIGIN );
return;
}
Expand Down
16 changes: 11 additions & 5 deletions test/e2e/specs/editor/various/change-detection.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,13 @@ test.describe( 'Change detection', () => {
).toBeDisabled(),
] );

// Autosave draft as same user should do full save, i.e. not dirty.
expect( await changeDetectionUtils.getIsDirty() ).toBe( false );
// With RTC enabled, all autosaves target an autosave revision. Vary our
// expectation accordingly.
const isRTCEnabled = Boolean(
await page.evaluate( () => window._wpCollaborationEnabled )
);

expect( await changeDetectionUtils.getIsDirty() ).toBe( isRTCEnabled );
} );

test( 'Should prompt to confirm unsaved changes for autosaved draft for non-content fields', async ( {
Expand Down Expand Up @@ -247,15 +252,16 @@ test.describe( 'Change detection', () => {
'Updating failed because you were offline. Please verify your connection and try again.'
)
).toBeVisible();

// Need to disable offline to allow reload and allow reconnect to sync provider.
await context.setOffline( false );

await expect(
page
.getByRole( 'region', { name: 'Editor top bar' } )
.getByRole( 'button', { name: 'Save draft' } )
).toBeEnabled();

// Need to disable offline to allow reload.
await context.setOffline( false );

expect( await changeDetectionUtils.getIsDirty() ).toBe( true );
} );

Expand Down
Loading