Skip to content

Navigation Link: Use optional chaining for linkUIref#67718

Closed
yogeshbhutkar wants to merge 1 commit into
WordPress:trunkfrom
yogeshbhutkar:67712-fix-type-error
Closed

Navigation Link: Use optional chaining for linkUIref#67718
yogeshbhutkar wants to merge 1 commit into
WordPress:trunkfrom
yogeshbhutkar:67712-fix-type-error

Conversation

@yogeshbhutkar

@yogeshbhutkar yogeshbhutkar commented Dec 9, 2024

Copy link
Copy Markdown
Contributor

Fixes: #67712

What?

An optional chaining for property access was introduced to access the properties of linkUIref to prevent the error described in the issue.

Why?

The absence of this optional chaining caused Uncaught TypeError and this PR is a fix in response to it.

How?

This PR fixes the issue by implementing optional chaining to resolve the error condition.

Testing Instructions

  1. Navigate to Patterns → Header, and select any pattern containing the Navigation Core Block.
  2. Select the Navigation Core Block and click the "plus" button.
  3. Click "+ Add block," then select "Browse All" to open the sidebar with available blocks.
  4. Click on any block in the sidebar to add it to the Navigation Core Block.
  5. Observe that there's no error in the console.

Screencast

Before:

Screen.Recording.2024-12-09.at.9.59.09.AM.mov

After:
After

@yogeshbhutkar yogeshbhutkar marked this pull request as ready for review December 9, 2024 04:33
@github-actions

github-actions Bot commented Dec 9, 2024

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.

Unlinked Accounts

The following contributors have not linked their GitHub and WordPress.org accounts: @darnado.

Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases.

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

Unlinked contributors: darnado.

Co-authored-by: yogeshbhutkar <yogeshbhutkar@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>

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

@jeryj jeryj 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've confirmed there's no more Uncaught TypeError when adding a block via this method. However, there may be a deeper issue here that the link ui should not be getting mounted at all after a block is added.

@Mamaduka Mamaduka added [Type] Bug An existing feature does not function as intended [Block] Navigation Affects the Navigation Block [Block] Navigation Link Affects the Navigation Link Block and removed [Block] Navigation Affects the Navigation Block labels Jan 13, 2025
@Mamaduka

Copy link
Copy Markdown
Member

@yogeshbhutkar, closing this in favor of #67760, which fixes the root cause of the issue.

@Mamaduka Mamaduka closed this Jan 14, 2025
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] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Uncaught TypeError when adding new blocks to the Navigation Core Block in Wordpress

3 participants