Skip to content

Commit 6dbf3ee

Browse files
authored
Merge pull request #860 from Automattic/fix/690-leave-site-alert
2 parents 4f13ec9 + d68f21e commit 6dbf3ee

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
88

99
### Fixed
1010

11+
* fix: prevent spurious "Leave site?" warning on new posts with custom statuses by @GaryJones in [#860](https://github.com/Automattic/Edit-Flow/pull/860)
1112
* fix: scope module asset loading to relevant pages only by @GaryJones in [#858](https://github.com/Automattic/Edit-Flow/pull/858)
1213
* fix: allow text selection in calendar overlay without triggering drag by @GaryJones in [#857](https://github.com/Automattic/Edit-Flow/pull/857)
1314
* fix: update post date to current time when publishing from custom status by @GaryJones in [#856](https://github.com/Automattic/Edit-Flow/pull/856)

modules/custom-status/lib/custom-status-block.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,15 @@ subscribe( function () {
2424
}
2525

2626
// For new posts, we need to force the default custom status.
27+
// Only update if the current status differs to avoid marking the post as dirty.
2728
const isCleanNewPost = select( 'core/editor' ).isCleanNewPost();
2829
if ( isCleanNewPost ) {
29-
dispatch( 'core/editor' ).editPost( {
30-
status: ef_default_custom_status,
31-
} );
30+
const currentStatus = select( 'core/editor' ).getEditedPostAttribute( 'status' );
31+
if ( currentStatus !== ef_default_custom_status ) {
32+
dispatch( 'core/editor' ).editPost( {
33+
status: ef_default_custom_status,
34+
} );
35+
}
3236
}
3337

3438
// If the save button exists, let's update the text if needed.

0 commit comments

Comments
 (0)