-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Add Link Preview Button to Open Link Control in Navigation Link Inspector #73731
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
Conversation
|
Size Change: +2.04 kB (+0.08%) Total Size: 2.59 MB
ℹ️ View Unchanged
|
getdave
left a comment
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.
Great work here. The upgrade to the panel is huge and aligns with our wider requirements for simplified editing because it allows users to utilise the Editable List View to edit Nav Menus with functionality parity.
However, it's absolutely key that we communicate when we're linking to an internal entity vs an external link.
Whilst I really enjoy the preview of the external link I am finding it hard to distinguish between when a link is to an internal entity (e.g. Post / Page) vs an external URL. That will be a problem for users and reduce the utility of this UI in resolving real world problems we identified during user testing.
To resolve this, I think the best route is as follows:
- ship a version of this which only uses this preview for entity links. External URLs show just the raw URL
- once merged, follow up with some explorations in using the preview for all link types but add visual affordances to clearly disambiguate the two types. Key elements we need include:
- entity type indicator (Post, Page...etc)
- post status indicator (Published, Draft...etc) - this one is required regardless
- external URL icon (we have this)
As part of any preview for external URLs we'd first need to enhance the url-details REST API endpoint to be more reliable in fetching the correct details. This will require using the HTML API instead of regex to parse the site HTML.
The approach above allows us to ship value early and then follow up with explorations.
Thanks again for the great work exploring routes here.
…ting a page link to a custom link
|
Flaky tests detected in f6b0d57. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/19976920094
|
| ...internalControlValue, | ||
| ...nonSettingsChanges, | ||
| // Explicitly set type and kind to undefined for custom links | ||
| ...( isCustomLink && { type: undefined, kind: undefined } ), |
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.
This seems logical. I'm amazed this isn't already part of the component 🤦
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.
I'm implementing this in #73825 as it is an unrelated bug fix
getdave
left a comment
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.
Nice work here 👏 The UI is getting really close.
In terms of implementation, I'm not convinced this should be a sub component of LinkControl. This UI is effectively a wrapper around LinkControl itself so it feels unusual that it is a sub component.
This feels similar to how we avoided using Popover inside LinkControl and instead required consumers to provide that themselves.
I would generally be in favour of creating a private block editor component which is not called LinkControl* (LinkPicker?) and instead has a more generic name. It can then consume the necessary parts of LinkControl (which we could expose as private APIs for now where necessary) or just the entire LinkControl component.
The benefit of this approach is that if/when we replace LinkControl we can swap out the "link picker" bit of the UI with the new implementation.
I also wonder, given that they are fairly significant changes to data handling, whether it's possible to extract some of the changes in shared to standalone PRs? LMK if you think that makes everything too complex or whether we'd have more confidence shipping in smaller chunks?
Thanks again 🙇
| * @param {Function} options.setAttributes - Standard setAttribute function | ||
| * @return {Function} Callback function to handle link changes | ||
| */ | ||
| export function useHandleLinkChange( { clientId, attributes, setAttributes } ) { |
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.
Unit/integration tests for this hook would increase confidence. If we were looking to break this PR down we could also ship this independently.
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.
For sure! I'm planning to add those. Hand't gotten to it yet. I think splitting some things out would be good, as this does contain some bug fixes and it's an already large PR.
I think this is a good idea.
It may make it more complicated, but it would give higher confidence. It would be slower, but safer. I think it's worth it for quality to split it up, and won't be significantly slower. I'll start working on that. |
Important! This still needs e2e tests for the new sidebar editing flow.
What?
Closes #73310
Adds a button with link preview details to the navigation link inspector. Clicking it opens the link control for searching for links.
Why?
How?
LinkPreviewButton, privately exported from the Block Editor componentsTesting Instructions
Testing Instructions for Keyboard
Screenshots or screencast
Screen.Recording.2025-12-05.at.10.23.08.AM.mov