Skip to content
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

Navigation block: Setting "hasIcon":false doesn't work if the navigation has "style":{} #61181

Closed
andersnoren opened this issue Apr 28, 2024 · 2 comments
Labels
[Block] Navigation Affects the Navigation Block Needs Testing Needs further testing to be confirmed. [Type] Bug An existing feature does not function as intended

Comments

@andersnoren
Copy link

andersnoren commented Apr 28, 2024

Description

If you set a navigation block to "hasIcon":false (Show icon button = false), the setting is reset in the editor and ignored on the front-end if the navigation block has anything in the "style":{} blob.

Step-by-step reproduction instructions

  1. Open header.html in Twenty Twenty-Four, or any other block theme.
  2. Add the following code:
<!-- wp:navigation {"hasIcon":false,"style":{"spacing":{"margin":{"top":"0"}}}} /-->
<!-- wp:navigation {"hasIcon":false} /-->
  1. Both are set to show a text label on mobile, but only the first has styles set. If you check the front-end on mobile, the first will have an icon, and the bottom one won't. If you check the editor, the first will be marked as "Show icon button" = true in the block settings, and the bottom one set to false, when both should be false.

Screenshots, screen recording, code snippet

image image

Environment info

WordPress 6.5.2
With or without Gutenberg active

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

@andersnoren andersnoren added the [Type] Bug An existing feature does not function as intended label Apr 28, 2024
@jordesign jordesign added Needs Testing Needs further testing to be confirmed. [Block] Navigation Affects the Navigation Block labels Apr 29, 2024
@amitraj2203
Copy link
Contributor

Hi @andersnoren, It's happening probably because in the code you mentioned the first nav has a missing ending }.

So the correct one is this:

<!-- wp:navigation {"hasIcon":false,"style":{"spacing":{"margin":{"top":"0"}}}} /-->
<!-- wp:navigation {"hasIcon":false} /-->

@andersnoren
Copy link
Author

@amitraj2203 You're entirely correct – thanks for catching that. Closing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Navigation Affects the Navigation Block Needs Testing Needs further testing to be confirmed. [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

3 participants