Skip to content

Navigation Link: Preserve custom labels during link updates#77186

Merged
ellatrix merged 6 commits into
WordPress:trunkfrom
yyppsk:fix/77169-update-text-via-link-edit-ui
May 14, 2026
Merged

Navigation Link: Preserve custom labels during link updates#77186
ellatrix merged 6 commits into
WordPress:trunkfrom
yyppsk:fix/77169-update-text-via-link-edit-ui

Conversation

@yyppsk

@yyppsk yyppsk commented Apr 9, 2026

Copy link
Copy Markdown
Contributor

What?

Closes : #77169

Reserve custom labels when the destination changes, but allow the Link popover text field to update the label when editing the same Navigation Page Link.

Why?

A recent change fixed a case where a custom Navigation Link label was being overwritten when a destination was selected for a link that previously had no URL. That preserved user-entered labels correctly when the link target changed.

However, that same logic now also suppresses valid label updates when the user is editing the text for the same Navigation Page Link. As a result, changing the text in the “Edit Link” popover no longer updates the visible label in the editor, which is a regression from the behavior in WordPress 6.9.

This change keeps the custom-label preservation introduced earlier, while restoring the ability to update the label when the destination itself has not changed.

How?

This updates the Navigation Link change handler so it only preserves the existing custom label when the selected destination changes.

When the user is still editing the same link target, the updated title from the Link UI is now passed through, allowing the block label to refresh correctly in the editor.

In practice, the logic now distinguishes between:

  • changing the link destination, where an existing custom label should remain untouched
  • editing the text for the current destination, where the new title should be applied

A regression test was also added to cover editing the text of an existing Navigation Page Link so this behavior stays protected going forward.

Testing Instructions

  1. Insert a Navigation block.
  2. Click the inserter and insert "Sample Page".
  3. Click the "Edit Link" button.
  4. Update the text and click the Apply button.
  5. The on-screen text changes as expected.

Screencast

Current 7.0 :

1c5259800a6d8bba9bf309610e40e3f2.mp4

Fixed :

Screen.Recording.2026-04-09.at.3.16.25.PM.mov

Use of AI Tools

I used AI tools to research about the issue and improve my code efficiency. I used Claude OPUS 4.6 and GPT Enterprise.

@github-actions github-actions Bot added the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label Apr 9, 2026
@github-actions

github-actions Bot commented Apr 9, 2026

Copy link
Copy Markdown

👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @yyppsk! In case you missed it, we'd love to have you join us in our Slack community.

If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information.

@github-actions github-actions Bot added the [Package] Block library /packages/block-library label Apr 9, 2026
@github-actions

github-actions Bot commented Apr 9, 2026

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: yyppsk <pranjalpratapsingh@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Co-authored-by: jeryj <jeryj@git.wordpress.org>
Co-authored-by: scruffian <scruffian@git.wordpress.org>
Co-authored-by: MaggieCabrera <onemaggie@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@MaggieCabrera

Copy link
Copy Markdown
Contributor

A regression test was also added to cover editing the text of an existing Navigation Page Link so this behavior stays protected going forward.

I think we are missing this from the PR, maybe it wasn't pushed?

@yyppsk

yyppsk commented Apr 10, 2026

Copy link
Copy Markdown
Contributor Author

I think we are missing this from the PR, maybe it wasn't pushed?

I’ve pushed the missing regression test now. It covers editing the text for the same existing Navigation Page Link so the updated title is passed through while preserving the earlier custom-label behavior when the destination changes.

@t-hamano t-hamano added the [Block] Navigation Link Affects the Navigation Link Block label Apr 27, 2026
@github-project-automation github-project-automation Bot moved this to 🔎 Needs Review in WordPress 7.0 Editor Tasks Apr 27, 2026
@t-hamano t-hamano changed the title fix: Preserve custom labels during link updates Navigation Link: Preserve custom labels during link updates May 7, 2026
@t-hamano t-hamano requested review from getdave and jeryj May 7, 2026 12:22
@t-hamano t-hamano added the Backport to WP 7.0 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta label May 7, 2026
Comment on lines +45 to +63
const isSameEntityLink =
!! updatedLink.id &&
updatedLink.id === attributes.id &&
updatedLink.kind === attributes.kind &&
updatedLink.type === attributes.type;

const isSameCustomLink =
! updatedLink.id &&
! attributes.id &&
updatedLink.url === attributes.url &&
updatedLink.kind === attributes.kind &&
updatedLink.type === attributes.type;

if (
! attributes.label ||
attributes.label === '' ||
isSameEntityLink ||
isSameCustomLink
) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The form has sections for editing both the title and the url. This logic looks like it's checking to see if the label is not empty AND the URL is the same.

Doesn't that mean if you change the title AND the link, then the title will not be updated?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great catch, thanks for pointing that out! I’m on it and will update it so that the inline Link UI clearly opts in for text updates. Meanwhile, the inspector sidebar LinkPicker will continue using the hook for link-only changes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’ve updated the approach so the inline Link UI explicitly opts into applying the submitted title, while the inspector Link Picker keeps the default behaviour of preserving existing custom labels. I also added coverage for changing both the text and destination, preserving the custom-label behaviour, and the bound-page inline edit flow.

@scruffian scruffian added the [Type] Bug An existing feature does not function as intended label May 14, 2026
name: 'Block: Page Link',
} )
.first();
await expect( navLinkBlock ).toBeVisible( { timeout: 10000 } );

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this? Playwright assertions have built-in auto-waiting...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, the explicit timeout is unnecessary here. I went a bit too conservative on this one. The assertion can rely on Playwright’s built-in auto-waiting, so this can be simplified.

}

if ( Object.keys( textUpdateAttributes ).length ) {
updateBlockAttributes( clientId, textUpdateAttributes );

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we have already called updateAttributes above, this will create a double undo point. I can replicate this in my testing.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing this one out as well.. In the normal path, updateAttributes() already receives the submitted title and computes the label, so the extra updateBlockAttributes() call is redundant and can create a second undo level..

@scruffian

Copy link
Copy Markdown
Contributor

This is quite a bad bug, so it would be good to get the fix into 7.0. On the other hand we are pretty late in the release cycle now, and this is not a minor, one liner, so I'm not sure it would be a good idea to introduce it at this late stage. There are workarounds for if you do need to edit the link title.

@scruffian scruffian left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm approving this as I think it's better to merge as is, rather than missing the RC4 cut off. Ideally we'd get those fixes in before we merge but it's not critical.

@yyppsk

yyppsk commented May 14, 2026

Copy link
Copy Markdown
Contributor Author

I'm approving this as I think it's better to merge as is, rather than missing the RC4 cut off. Ideally we'd get those fixes in before we merge but it's not critical.

Thanks for the review and approval, really appreciate you getting this in.

I agree those follow-up concerns would ideally be addressed, and I’m happy to take them up in a follow-up PR if needed after this lands.

@ellatrix ellatrix merged commit 8785999 into WordPress:trunk May 14, 2026
49 of 54 checks passed
@github-project-automation github-project-automation Bot moved this from 🔎 Needs Review to ✅ Done in WordPress 7.0 Editor Tasks May 14, 2026
@github-actions github-actions Bot added this to the Gutenberg 23.3 milestone May 14, 2026
@github-actions github-actions Bot removed the Backport to WP 7.0 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta label May 14, 2026
gutenbergplugin pushed a commit that referenced this pull request May 14, 2026
Co-authored-by: yyppsk <pranjalpratapsingh@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Co-authored-by: jeryj <jeryj@git.wordpress.org>
Co-authored-by: scruffian <scruffian@git.wordpress.org>
Co-authored-by: MaggieCabrera <onemaggie@git.wordpress.org>
@github-actions github-actions Bot added the Backported to WP Core Pull request that has been successfully merged into WP Core label May 14, 2026
@github-actions

Copy link
Copy Markdown

I just cherry-picked this PR to the wp/7.0 branch to get it included in the next release: dba1cbd

pento pushed a commit to WordPress/wordpress-develop that referenced this pull request May 14, 2026
This updates the pinned hash from the `gutenberg` from `c15cef1d6b07f666df28dac0383bafb0edfe0914 ` to `3a4e8d1418d25da83b70158bcaabf65580690b6b`.

The following changes are included:

- [WP.7.0] Admin UI: Backport accessibility fixes (WordPress/gutenberg#77617, WordPress/gutenberg#78001) (WordPress/gutenberg#78002)
- Fix: Shortcode block does not render in Navigation Overlay (WordPress/gutenberg#77511)
- feat: Enhance Connectors page on read-only file system (WordPress/gutenberg#77521)
- Connectors: Avoid using centered text (WordPress/gutenberg#78125)
- Revisions: Add tooltip to diff marker buttons  (WordPress/gutenberg#77690)
- Add backport for WP_ALLOW_COLLABORATION (WordPress/gutenberg#78160)
- Add aria-label to Revisions button in Post Summary sidebar (WordPress/gutenberg#78140)
- Revisions diff markers: enforce 24×24px minimum target size (WCAG 2.5.8) (WordPress/gutenberg#77671)
- Connectors: Replace @wordpress/ui Link and Notice usage (WordPress/gutenberg#78117)
- Connectors: Increase right padding of callout for mobile layout (WordPress/gutenberg#78126)
- isFulfilled: don't change resolution state, call in resolveSelect (WordPress/gutenberg#78201)
- Connectors: Restyle AI plugin callout with pastel background and beaker decoration (WordPress/gutenberg#78243)
- Block supports: Optimize custom CSS class rendering and parsing (WordPress/gutenberg#78217)
- Block Inspector: Hide Styles tab in preview mode (WordPress/gutenberg#78230)
- Navigation Link: Preserve custom labels during link updates (WordPress/gutenberg#77186)
- Editor: Fix Visual Revisions meta keys overlap (WordPress/gutenberg#78156)
- Editor: Disable Visual Revisions when classic meta boxes are present (WordPress/gutenberg#78249) (WordPress/gutenberg#78286)
- Revisions: Scale diff markers width with user text-size preference (WordPress/gutenberg#78273)

A full list of changes can be found on GitHub: https://github.com/WordPress/gutenberg/compare/c15cef1d6b07f666df28dac0383bafb0edfe0914…3a4e8d1418d25da83b70158bcaabf65580690b6b.

Log created with:

git log --reverse --format="- %s" c15cef1d6b07f666df28dac0383bafb0edfe0914..3a4e8d1418d25da83b70158bcaabf65580690b6b | sed 's|#\([0-9][0-9]*\)|https://github.com/WordPress/gutenberg/pull/\1|g; /github\.com\/WordPress\/gutenberg\/pull/!d' | pbcopy

See #64595.

git-svn-id: https://develop.svn.wordpress.org/branches/7.0@62360 602fd350-edb4-49c9-b593-d223f7449a82
markjaquith pushed a commit to markjaquith/WordPress that referenced this pull request May 14, 2026
This updates the pinned hash from the `gutenberg` from `c15cef1d6b07f666df28dac0383bafb0edfe0914 ` to `3a4e8d1418d25da83b70158bcaabf65580690b6b`.

The following changes are included:

- [WP.7.0] Admin UI: Backport accessibility fixes (WordPress/gutenberg#77617, WordPress/gutenberg#78001) (WordPress/gutenberg#78002)
- Fix: Shortcode block does not render in Navigation Overlay (WordPress/gutenberg#77511)
- feat: Enhance Connectors page on read-only file system (WordPress/gutenberg#77521)
- Connectors: Avoid using centered text (WordPress/gutenberg#78125)
- Revisions: Add tooltip to diff marker buttons  (WordPress/gutenberg#77690)
- Add backport for WP_ALLOW_COLLABORATION (WordPress/gutenberg#78160)
- Add aria-label to Revisions button in Post Summary sidebar (WordPress/gutenberg#78140)
- Revisions diff markers: enforce 24×24px minimum target size (WCAG 2.5.8) (WordPress/gutenberg#77671)
- Connectors: Replace @wordpress/ui Link and Notice usage (WordPress/gutenberg#78117)
- Connectors: Increase right padding of callout for mobile layout (WordPress/gutenberg#78126)
- isFulfilled: don't change resolution state, call in resolveSelect (WordPress/gutenberg#78201)
- Connectors: Restyle AI plugin callout with pastel background and beaker decoration (WordPress/gutenberg#78243)
- Block supports: Optimize custom CSS class rendering and parsing (WordPress/gutenberg#78217)
- Block Inspector: Hide Styles tab in preview mode (WordPress/gutenberg#78230)
- Navigation Link: Preserve custom labels during link updates (WordPress/gutenberg#77186)
- Editor: Fix Visual Revisions meta keys overlap (WordPress/gutenberg#78156)
- Editor: Disable Visual Revisions when classic meta boxes are present (WordPress/gutenberg#78249) (WordPress/gutenberg#78286)
- Revisions: Scale diff markers width with user text-size preference (WordPress/gutenberg#78273)

A full list of changes can be found on GitHub: https://github.com/WordPress/gutenberg/compare/c15cef1d6b07f666df28dac0383bafb0edfe0914…3a4e8d1418d25da83b70158bcaabf65580690b6b.

Log created with:

git log --reverse --format="- %s" c15cef1d6b07f666df28dac0383bafb0edfe0914..3a4e8d1418d25da83b70158bcaabf65580690b6b | sed 's|#\([0-9][0-9]*\)|https://github.com/WordPress/gutenberg/pull/\1|g; /github\.com\/WordPress\/gutenberg\/pull/!d' | pbcopy

See #64595.
Built from https://develop.svn.wordpress.org/branches/7.0@62360


git-svn-id: http://core.svn.wordpress.org/branches/7.0@61641 1a063a9b-81f0-0310-95a4-ce76da25c4cd
pento pushed a commit to WordPress/wordpress-develop that referenced this pull request May 14, 2026
This updates the pinned hash from the `gutenberg` from `c15cef1d6b07f666df28dac0383bafb0edfe0914 ` to `3a4e8d1418d25da83b70158bcaabf65580690b6b`.

The following changes are included:

- [WP.7.0] Admin UI: Backport accessibility fixes (WordPress/gutenberg#77617, WordPress/gutenberg#78001) (WordPress/gutenberg#78002)
- Fix: Shortcode block does not render in Navigation Overlay (WordPress/gutenberg#77511)
- feat: Enhance Connectors page on read-only file system (WordPress/gutenberg#77521)
- Connectors: Avoid using centered text (WordPress/gutenberg#78125)
- Revisions: Add tooltip to diff marker buttons  (WordPress/gutenberg#77690)
- Add backport for WP_ALLOW_COLLABORATION (WordPress/gutenberg#78160)
- Add aria-label to Revisions button in Post Summary sidebar (WordPress/gutenberg#78140)
- Revisions diff markers: enforce 24×24px minimum target size (WCAG 2.5.8) (WordPress/gutenberg#77671)
- Connectors: Replace @wordpress/ui Link and Notice usage (WordPress/gutenberg#78117)
- Connectors: Increase right padding of callout for mobile layout (WordPress/gutenberg#78126)
- isFulfilled: don't change resolution state, call in resolveSelect (WordPress/gutenberg#78201)
- Connectors: Restyle AI plugin callout with pastel background and beaker decoration (WordPress/gutenberg#78243)
- Block supports: Optimize custom CSS class rendering and parsing (WordPress/gutenberg#78217)
- Block Inspector: Hide Styles tab in preview mode (WordPress/gutenberg#78230)
- Navigation Link: Preserve custom labels during link updates (WordPress/gutenberg#77186)
- Editor: Fix Visual Revisions meta keys overlap (WordPress/gutenberg#78156)
- Editor: Disable Visual Revisions when classic meta boxes are present (WordPress/gutenberg#78249) (WordPress/gutenberg#78286)
- Revisions: Scale diff markers width with user text-size preference (WordPress/gutenberg#78273)

A full list of changes can be found on GitHub: https://github.com/WordPress/gutenberg/compare/c15cef1d6b07f666df28dac0383bafb0edfe0914…3a4e8d1418d25da83b70158bcaabf65580690b6b.

Log created with:

`git log --reverse --format="- %s" c15cef1d6b07f666df28dac0383bafb0edfe0914..3a4e8d1418d25da83b70158bcaabf65580690b6b | sed 's|#\([0-9][0-9]*\)|https://github.com/WordPress/gutenberg/pull/\1|g; /github\.com\/WordPress\/gutenberg\/pull/!d' | pbcopy`

Reviewed by desrosj.
Merges [62360] to `trunk`.

See #64595.

git-svn-id: https://develop.svn.wordpress.org/trunk@62361 602fd350-edb4-49c9-b593-d223f7449a82
markjaquith pushed a commit to markjaquith/WordPress that referenced this pull request May 14, 2026
This updates the pinned hash from the `gutenberg` from `c15cef1d6b07f666df28dac0383bafb0edfe0914 ` to `3a4e8d1418d25da83b70158bcaabf65580690b6b`.

The following changes are included:

- [WP.7.0] Admin UI: Backport accessibility fixes (WordPress/gutenberg#77617, WordPress/gutenberg#78001) (WordPress/gutenberg#78002)
- Fix: Shortcode block does not render in Navigation Overlay (WordPress/gutenberg#77511)
- feat: Enhance Connectors page on read-only file system (WordPress/gutenberg#77521)
- Connectors: Avoid using centered text (WordPress/gutenberg#78125)
- Revisions: Add tooltip to diff marker buttons  (WordPress/gutenberg#77690)
- Add backport for WP_ALLOW_COLLABORATION (WordPress/gutenberg#78160)
- Add aria-label to Revisions button in Post Summary sidebar (WordPress/gutenberg#78140)
- Revisions diff markers: enforce 24×24px minimum target size (WCAG 2.5.8) (WordPress/gutenberg#77671)
- Connectors: Replace @wordpress/ui Link and Notice usage (WordPress/gutenberg#78117)
- Connectors: Increase right padding of callout for mobile layout (WordPress/gutenberg#78126)
- isFulfilled: don't change resolution state, call in resolveSelect (WordPress/gutenberg#78201)
- Connectors: Restyle AI plugin callout with pastel background and beaker decoration (WordPress/gutenberg#78243)
- Block supports: Optimize custom CSS class rendering and parsing (WordPress/gutenberg#78217)
- Block Inspector: Hide Styles tab in preview mode (WordPress/gutenberg#78230)
- Navigation Link: Preserve custom labels during link updates (WordPress/gutenberg#77186)
- Editor: Fix Visual Revisions meta keys overlap (WordPress/gutenberg#78156)
- Editor: Disable Visual Revisions when classic meta boxes are present (WordPress/gutenberg#78249) (WordPress/gutenberg#78286)
- Revisions: Scale diff markers width with user text-size preference (WordPress/gutenberg#78273)

A full list of changes can be found on GitHub: https://github.com/WordPress/gutenberg/compare/c15cef1d6b07f666df28dac0383bafb0edfe0914…3a4e8d1418d25da83b70158bcaabf65580690b6b.

Log created with:

`git log --reverse --format="- %s" c15cef1d6b07f666df28dac0383bafb0edfe0914..3a4e8d1418d25da83b70158bcaabf65580690b6b | sed 's|#\([0-9][0-9]*\)|https://github.com/WordPress/gutenberg/pull/\1|g; /github\.com\/WordPress\/gutenberg\/pull/!d' | pbcopy`

Reviewed by desrosj.
Merges [62360] to `trunk`.

See #64595.
Built from https://develop.svn.wordpress.org/trunk@62361


git-svn-id: http://core.svn.wordpress.org/trunk@61642 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Backported to WP Core Pull request that has been successfully merged into WP Core [Block] Navigation Link Affects the Navigation Link Block First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository [Package] Block library /packages/block-library [Type] Bug An existing feature does not function as intended

Projects

Development

Successfully merging this pull request may close these issues.

Page Link block: Cannot update text via link editing UI

6 participants