-
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
Fix nav editor links to correctly persist new tab target attribute #30956
Conversation
Size Change: +166 B (0%) Total Size: 1.46 MB
ℹ️ View Unchanged
|
There may be a wider follow-up to this required where we methodically go through all the possible nav menu item fields and ensure they are correctly mapped to block attributes (and the inverse!). We'll need some unit tests for this to avoid future regressions. |
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 @getdave this manually tests well for me and code looks reasonable . I'm not as familiar with the serialization here, so a +1 from other folks working on the navigation editor wouldn't hurt.
I tested this against the old menu editor, navigation editor, and populating a navigation block from a menu.
menu.mp4
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.
Looks good 👍
Description
Fixes #30323.
Currently within the Navigation Editor the feature to cause a nav link to "Open in new tab" does not work.
Whilst it is possible to toggle the control and have the state persist within the editor, if you reload the editor the setting state is not persisted (ie: it is always "off").
The reason for this is that that the
settings
property on the underlying<LinkControl>
component is calledopensInNewTab
whereas the menuItem data (when stored in the database) expects atarget
property with a string value of_blank
. This mismatch has not been accounted for when translatingcore/navigation-link
blocks into the equivalent menu item to be persisted into the database.This PR updates things so that
target
attribute to_blank
if the block hasopensInNewTab
set totrue
.opensInNewTab
property is set based on the presence of the string_blank
as the value of the menu item'starget
property.🙏 Note: I'd appreciate a confidence check that the value
_blank
is the correct string value as used on the old WordPress menu page.How has this been tested?
Manual Testing
In the Navigation Editor (experimental):
Opens in new tab
to "on".Opens in new tab
setting is still set to "on".Opens in new tab
setting to "off".Opens in new tab
setting is still set to "off".Note is is important to check that you can toggle this setting on and off. Also repeat for multiple nav items within a menu and using different link types.
Automated Tests
Run
npm run test-unit packages/edit-navigation/src/store/test/
. See all ✅ .Screenshots
Screen.Capture.on.2021-04-19.at.11-47-26.mov
Types of changes
Bug fix (non-breaking change which fixes an issue)
Checklist:
*.native.js
files for terms that need renaming or removal).