Skip to content

Conversation

Infinite-Null
Copy link
Contributor

@Infinite-Null Infinite-Null commented Jul 14, 2025

What?

Follow up of: #67262
Add opensInNewTab: false to the default attributes when resetting navigation link fields.

Why?

This PR ensures that when navigation link attributes are reset, the opensInNewTab attribute is also properly reset to its default value of false.

How?

Added opensInNewTab: false to the object passed to setAttributes() in the reset functionality within the Controls component of the navigation-link block. This ensures all navigation link attributes are consistently reset to their default values when the clear action is triggered.

Testing Instructions

  1. Open a post or page in the block editor.
  2. Insert a Navigation block.
  3. Add a Navigation Link block within the Navigation block.
  4. Set the link URL, description, and enable "Open in new tab".
  5. Reset the link using the reset all functionality.
  6. Verify that all fields are back to there default state, including the "Open in new tab" setting.

Screencast

Screen.Recording.2025-07-14.at.5.49.20.PM.mov

@Infinite-Null Infinite-Null marked this pull request as ready for review July 14, 2025 12:21
Copy link

github-actions bot commented Jul 14, 2025

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: Infinite-Null <ankitkumarshah@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: getdave <get_dave@git.wordpress.org>

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

@Mamaduka Mamaduka added [Type] Code Quality Issues or PRs that relate to code quality [Block] Navigation Link Affects the Navigation Link Block labels Jul 14, 2025
@Infinite-Null
Copy link
Contributor Author

Hi @t-hamano, I have created the follow-up for PR #67262, adding the missing open in new tab in resetAll for the Navigation Link block. Please review it at your convenience. Thank You!

Copy link
Member

@Mamaduka Mamaduka left a comment

Choose a reason for hiding this comment

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

Good catch, @Infinite-Null!

@Mamaduka Mamaduka added the props-bot Manually triggers Props Bot to ensure the list of props is up to date. label Jul 14, 2025
@github-actions github-actions bot removed the props-bot Manually triggers Props Bot to ensure the list of props is up to date. label Jul 14, 2025
@@ -187,6 +187,7 @@ function Controls( { attributes, setAttributes, setIsLabelFieldFocused } ) {
url: '',
description: '',
rel: '',
opensInNewTab: false,
Copy link
Contributor

Choose a reason for hiding this comment

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

Good catch 👍

The issue is that this approach is already not sustainable. Any other props that are added probably will get missed from this list and the same bug will reoccur.

Not blocking on this PR landing but something to consider.

Copy link
Member

Choose a reason for hiding this comment

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

The issue is that this approach is already not sustainable. Any other props that are added probably will get missed from this list and the same bug will reoccur.

That's kind of the unfortunate deal with attributes. A developer has to cover all the corners when adding a new attribute.

@Mamaduka Mamaduka added the props-bot Manually triggers Props Bot to ensure the list of props is up to date. label Jul 14, 2025
@github-actions github-actions bot removed the props-bot Manually triggers Props Bot to ensure the list of props is up to date. label Jul 14, 2025
@Mamaduka Mamaduka merged commit b527b04 into WordPress:trunk Jul 14, 2025
73 of 113 checks passed
@github-actions github-actions bot added this to the Gutenberg 21.3 milestone Jul 14, 2025
cbravobernal pushed a commit that referenced this pull request Jul 15, 2025
Co-authored-by: Infinite-Null <ankitkumarshah@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: getdave <get_dave@git.wordpress.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Navigation Link Affects the Navigation Link Block [Type] Code Quality Issues or PRs that relate to code quality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants