-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Flag invalid Navigation Link items. #31716
Conversation
7cd7744
to
8a0e0d7
Compare
Size Change: +645 B (0%) Total Size: 1.14 MB
ℹ️ View Unchanged
|
Thanks for taking a look. These changes broke the e2e tests, which I think indicates that some of those tests depend on invalid links showing up normally.
Agreed, I'd appreciate a look from @WordPress/gutenberg-core |
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.
Thanks! I tested and works as expected. I didn't test with CPTs though..
Can we extract this in a separate hook? What do you think?
9a5eaef
to
81eb6c7
Compare
81eb6c7
to
63493a2
Compare
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.
ea14935
to
5982a89
Compare
5982a89
to
ff86d7a
Compare
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.
Overall, this looks really solid! Nice work @vcanales ✨ As discussed in chat it looks like e2e mocks need to be updated to handle the new getEntityRecord
call to fix tests.
One usability question I had was around how do folks know why this is invalid and how to fix it? Current workflows allow us to create drafts within the search suggestion, so seeing this from the start may be surprising.
draft.mp4
ff86d7a
to
db5f71d
Compare
db5f71d
to
f0f131c
Compare
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.
Thanks for working on this! A couple minor questions below, and some thoughts about the Draft status:
The current menus screen only flags deleted posts/pages as invalid. Drafts are kept in the menu:
The front end behaviour also differs with current menu showing draft pages (though they link to a 404 unless user is logged in/able to access the draft), while the Navigation block hides them.
I think unless we have really good reasons to change this, we should follow current behaviour so users know what to expect. This would also help solve @gwwar 's point about creating draft pages in the Navigation block.
3c21206
to
ad6df50
Compare
ad6df50
to
7777d4d
Compare
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.
Giving tentative approval as this is working solidly for me. I would encourage another sanity check if you can get it. Nice work!
5d18b97
to
dda0fb7
Compare
Worth noting that if you are using the menu item request rest api endpoint, there is a field called |
dda0fb7
to
95ec8f3
Compare
2934840
to
579700d
Compare
579700d
to
45e19e0
Compare
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.
Thanks for persisting with this! It's almost there, just a few comments below.
Necessary as the invalid links logic calls `getEntityRecord` on pages, and if they don't exist a 404 error is thrown, causing tests using `mocklSearchResponse` to fail, as the pages being looked up don't exist. Using `createPages` does not fix this issue.
45e19e0
to
bad275f
Compare
Description
Re. #23573
Following the criteria used when deciding whether or not to render a Navigation Link item server-side, mark those items that would not be rendered as Invalid in the editor, in order to match the behaviour of the menu editor found on
nav-menus.php
.The steps taken to decide whether or not an element is invalid are the following:
If those conditions are met, check if
If either of those is true, invalidate.
How has this been tested?
Manually tested by:
Both modified pages should now be flagged with the text "(Invalid)".
And
All Drafts and trashed posts should be flagged with the text "(Invalid)".
Screenshots
Types of changes
Checklist:
*.native.js
files for terms that need renaming or removal).