-
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
StartPageOptions: improve conditions to show modal only on a brand new page #54245
Conversation
Size Change: +7.54 kB (0%) Total Size: 1.52 MB
ℹ️ View Unchanged
|
Th editor package has selector that checks if it’s a new post/page. I think the PostTitle component uses it to set focus on newly created content. What do you think about using that selector? Sorry, I’m AFK at the moment so can’t search the codebase. Found it: https://github.com/WordPress/gutenberg/blob/trunk/packages/editor/src/store/selectors.js#L151 |
Good idea! Its name is |
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.
Tests well for me and makes the code easier to understand 😄
Nice job! |
Thank you, @jsnajdr! As a follow-up, it would be nice to introduce e2e tests for this feature. It's not widely adopted to get regression reports from the users, but it is also good to catch them early. |
Fixes #54227.
The condition that inspects the current post, and triggers displaying the pattern selection modal, it was wrong. It fired also in two cases where it shouldn't fire:
See the comments in #54227 for more details.
The fix improves the condition in several ways:
isEditedPostSaveable
selector, check explicitly thetitle
,excerpt
andcontent
attributes of the postisEditedPostSaveable
, we're not evaluating theisSavingPost
condition (is save in progress?) which is irrelevant for usisEditedPostEmpty
to detect empty content in a more optimized way -- ifpost.content
is a function, we no longer call it all the timeisEditedPostDirty
to verify that the post is brand new, and not just an edit of existing non-empty postHow to test:
Verify that the patterns modal is shown when it should be (when creating a new page), and that it's not shown in the two reported cases: