Editor: Fix move to trash redirect save race conditions.#18275
Conversation
|
While I don't think it needs to be a blocker, we should definitely have an end-to-end test case covering this behavior. My thinking was something in it( 'Should not prompt to confirm unsaved changes when trashing an existing post', async () => {
await createNewPost( {
title: 'My New Post',
} );
await saveDraft();
// ...trash post and assert no dialog
} ); |
|
Per #17427 (comment), do we still have the potential that a 500 server response can occur when the save occurs after trashing the post? My thinking is something along the lines of:
At step 4, isn't it true that since the save occurs after the trashing, the payload (the edited title) may cause a failed response? gutenberg/packages/editor/src/store/actions.js Lines 347 to 357 in 61753df |
Why are those values "stale" ? Is it that |
Done 😄
Yeah, but you would want to know you have unsaved changes then.
Yes, exactly. I already had a comment there, and I've made it clearer now. |
The current Travis test failure appears to suggest an issue exists: It's also not surfaced to the user in any meaningful way: There is no notice, and the "Saving" button never changes back to a finished state. |
| await page.click( '.editor-post-trash.components-button' ); | ||
|
|
||
| // Check that the dialog didn't show. | ||
| await assertIsDirty( false ); |
There was a problem hiding this comment.
assertIsDirty does its check by performing a reload, which I sense would conflict with clicking the trash button. Rather, I think we probably want to press Trash and wait for the page to navigate to the post list (maybe check the success notice as well), optionally adding a 'dialog' even to short-cut the test failure when encountered.
There was a problem hiding this comment.
This works because refreshing a page with a dialog doesn't get rid of the dialog. So if navigation didn't happen because the dialog stopped it, assertIsDirty wouldn't assert false.
| await page.type( '.editor-post-title__input', 'Hello World' ); | ||
|
|
||
| // Save | ||
| await Promise.all( [ |
There was a problem hiding this comment.
Aside: There's a helper for this saveDraft. The file as a whole could do for some refactoring to use it.
packages/editor/src/components/unsaved-changes-warning/index.js
Outdated
Show resolved
Hide resolved
|
I suspect the 500 seen in the test log is a result of the fact that a I will suggest that we revert the commit adding the test case, and reintroduce a fixed implementation in a subsequent pull request. |
This reverts commit 4d58c79.
* Editor: Fix move to trash redirect save race conditions. * Editor: Add e2e test. * Editor: Expand comment. * Fix BrowserURL capitalization * Revert "Editor: Add e2e test." This reverts commit 4d58c79.
* Editor: Fix move to trash redirect save race conditions. * Editor: Add e2e test. * Editor: Expand comment. * Fix BrowserURL capitalization * Revert "Editor: Add e2e test." This reverts commit 4d58c79.
The list of included fixes is: WordPress/gutenberg#18183 WordPress/gutenberg#18194 WordPress/gutenberg#18230 WordPress/gutenberg#18275 WordPress/gutenberg#18287 Updated packages: - @wordpress/block-editor@3.2.4 - @wordpress/block-library@2.9.5 - @wordpress/edit-post@3.8.5 - @wordpress/editor@9.7.5 - @wordpress/format-library@1.9.4 Props @aduth, @mcsf, @youknowriad, @johnbillion. Fixes #48502. git-svn-id: https://develop.svn.wordpress.org/trunk@46656 602fd350-edb4-49c9-b593-d223f7449a82
The list of included fixes is: WordPress/gutenberg#18183 WordPress/gutenberg#18194 WordPress/gutenberg#18230 WordPress/gutenberg#18275 WordPress/gutenberg#18287 Updated packages: - @wordpress/block-editor@3.2.4 - @wordpress/block-library@2.9.5 - @wordpress/edit-post@3.8.5 - @wordpress/editor@9.7.5 - @wordpress/format-library@1.9.4 Props @aduth, @mcsf, @youknowriad, @johnbillion. Fixes #48502. git-svn-id: https://develop.svn.wordpress.org/trunk@46656 602fd350-edb4-49c9-b593-d223f7449a82
The list of included fixes is: WordPress/gutenberg#18183 WordPress/gutenberg#18194 WordPress/gutenberg#18230 WordPress/gutenberg#18275 WordPress/gutenberg#18287 Updated packages: - @wordpress/block-editor@3.2.4 - @wordpress/block-library@2.9.5 - @wordpress/edit-post@3.8.5 - @wordpress/editor@9.7.5 - @wordpress/format-library@1.9.4 Props @aduth, @mcsf, @youknowriad, @johnbillion. Fixes #48502. Built from https://develop.svn.wordpress.org/trunk@46656 git-svn-id: http://core.svn.wordpress.org/trunk@46456 1a063a9b-81f0-0310-95a4-ce76da25c4cd
The list of included fixes is: WordPress/gutenberg#18183 WordPress/gutenberg#18194 WordPress/gutenberg#18230 WordPress/gutenberg#18275 WordPress/gutenberg#18287 Updated packages: - @wordpress/block-editor@3.2.4 - @wordpress/block-library@2.9.5 - @wordpress/edit-post@3.8.5 - @wordpress/editor@9.7.5 - @wordpress/format-library@1.9.4 Props @aduth, @mcsf, @youknowriad, @johnbillion. Fixes #48502. Built from https://develop.svn.wordpress.org/trunk@46656 git-svn-id: https://core.svn.wordpress.org/trunk@46456 1a063a9b-81f0-0310-95a4-ce76da25c4cd
The list of included fixes is: WordPress/gutenberg#18183 WordPress/gutenberg#18194 WordPress/gutenberg#18230 WordPress/gutenberg#18275 WordPress/gutenberg#18287 Updated packages: - @wordpress/block-editor@3.2.4 - @wordpress/block-library@2.9.5 - @wordpress/edit-post@3.8.5 - @wordpress/editor@9.7.5 - @wordpress/format-library@1.9.4 Props @aduth, @mcsf, @youknowriad, @johnbillion. Fixes #48502. Built from https://develop.svn.wordpress.org/trunk@46656
The list of included fixes is: WordPress/gutenberg#18183 WordPress/gutenberg#18194 WordPress/gutenberg#18230 WordPress/gutenberg#18275 WordPress/gutenberg#18287 Updated packages: - @wordpress/block-editor@3.2.4 - @wordpress/block-library@2.9.5 - @wordpress/edit-post@3.8.5 - @wordpress/editor@9.7.5 - @wordpress/format-library@1.9.4 Props @aduth, @mcsf, @youknowriad, @johnbillion. Fixes #48502. git-svn-id: http://develop.svn.wordpress.org/trunk@46656 602fd350-edb4-49c9-b593-d223f7449a82
Description
Two things were causing the unsaved changes warning to trigger when trashing a post:
BrowserUrlwas navigating away as soon as the new post status was received, causing the redirection to happen while the post was still technically dirty.gutenberg/packages/edit-post/src/components/browser-url/index.js
Lines 44 to 51 in 61753df
UnsavedChangesWarninglistener fired immediately with stale values.gutenberg/packages/editor/src/components/unsaved-changes-warning/index.js
Lines 29 to 36 in 61753df
That was fixed by calling the selector from within the listener.
How has this been tested?
It was verified that trashing a post no longer triggers an unsaved changes warning.
Types of Changes
Bug Fix: Trashing a post no longer triggers an unsaved changes warning.
Checklist: