-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Editor: Make sure that all edits after saving are considered "persistent". #17888
Editor: Make sure that all edits after saving are considered "persistent". #17888
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think it may be worth including the e2e test @mcsf provided?
I'd like to, but when I tested last night I noticed that the test always passed if Puppeteer ran headless and with no It's always preferable to add a test along with these fixes, so — if you can timebox it — adding a properly working test would be good, otherwise just get the fix in. :) For other readers: this is the test in question: #17852 (comment) I then tried a different version, relying on diff --git a/packages/e2e-tests/specs/change-detection.test.js b/packages/e2e-tests/specs/change-detection.test.js
index 0f384d7c3..9d0d7208b 100644
--- a/packages/e2e-tests/specs/change-detection.test.js
+++ b/packages/e2e-tests/specs/change-detection.test.js
@@ -6,6 +6,7 @@ import {
createNewPost,
pressKeyWithModifier,
ensureSidebarOpened,
+ openDocumentSettingsSidebar,
publishPost,
} from '@wordpress/e2e-test-utils';
@@ -204,6 +205,50 @@ describe( 'Change detection', () => {
expect( hadInterceptedSave ).toBe( false );
} );
+ it( 'Should mark consecutive edits of a same attribute dirty if there was a save in between', async () => {
+ await clickBlockAppender();
+ await page.keyboard.type( 'Hello, World' );
+
+ // Save and wait for "Saved" to confirm save complete.
+ await Promise.all( [
+ page.waitForSelector( '.editor-post-saved-state.is-saved' ),
+ pressKeyWithModifier( 'primary', 'S' ),
+ ] );
+
+ // Assert clean editor
+ expect( await page.$( '.editor-post-saved-state.is-saved' ) )
+ .toBeTruthy();
+
+ // Open the sidebar, switch to block settings
+ await openDocumentSettingsSidebar();
+ await page.click( '.edit-post-sidebar__panel-tab[data-label="Block"]' );
+
+ // Make sure our paragraph is selected
+ await page.click( '[data-type="core/paragraph"]' );
+
+ // In the block's inspector controls, increase the font size
+ await page.select( '.components-select-control__input', 'large' );
+ await page.click( '[data-type="core/paragraph"]' );
+
+ // Assert dirtiness
+ await page.waitForSelector( '.editor-post-save-draft' );
+ expect( await page.$( '.editor-post-saved-state.is-saved' ) ).toBeNull();
+
+ // Save and wait for "Saved" to confirm save complete.
+ await Promise.all( [
+ page.waitForSelector( '.editor-post-saved-state.is-saved' ),
+ pressKeyWithModifier( 'primary', 'S' ),
+ ] );
+
+ // Increase the font size one more level
+ await page.select( '.components-select-control__input', 'larger' );
+ await page.click( '[data-type="core/paragraph"]' );
+
+ // Assert dirtiness
+ await page.waitForSelector( '.editor-post-save-draft' );
+ expect( await page.$( '.editor-post-saved-state.is-saved' ) ).toBeNull();
+ } );
+
it( 'Should prompt if save failed', async () => {
await page.type( '.editor-post-title__input', 'Hello World' ); |
I'm merging but please consider a test for this as a follow-up |
I'm merging but please consider a test for this as a follow-up
@epiqueras, mind filing an issue? ty!
|
Fixes #17852
Description
This PR fixes the issue discussed in #17852, by making sure that any change after a save is considered as persistent for undo level creation and change detection.
How has this been tested?
It was verified that #17852 was fixed and all the tests pass.
Types of Changes
Bug Fix: Fix an issue where editing the same block attribute after saving would not dirty the post again.
Checklist: