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

Quadrat: open in a new tab not working for menu links #4813

Closed
escapemanuele opened this issue Oct 11, 2021 · 3 comments · Fixed by WordPress/gutenberg#35634
Closed

Quadrat: open in a new tab not working for menu links #4813

escapemanuele opened this issue Oct 11, 2021 · 3 comments · Fixed by WordPress/gutenberg#35634

Comments

@escapemanuele
Copy link

escapemanuele commented Oct 11, 2021

Steps to replicate

image

image

Result

  • Clicking on the link, the linked page opens in the same tab
  • With a different theme this does not happen

Expected

Setting a menu item to open in a new tab should result in the linked page opening in a new tab

  • User report: 4366104-zd-woothemes
@mikachan
Copy link
Member

I can replicate this in Blockbase & Co and I think it's a Gutenberg issue, but I don't know Gutenberg well enough to know how to debug this properly.

The menu in the header template doesn't render with a target="_blank" or a title:

image

However, if I add a Navigation block through the editor and specify a menu, the links will be added as individual blocks, like this:

<!-- wp:navigation -->
<!-- wp:navigation-link {"label":"Home","type":"page","id":8,"url":"/home/","kind":"post-type","isTopLevelLink":true} /-->

<!-- wp:navigation-link {"label":"FAQs","type":"page","id":127,"opensInNewTab":true,"url":"/faqs/","title":"FAQTitle","kind":"post-type","isTopLevelLink":true} /-->

<!-- wp:navigation-link {"label":"Cover Block Spacing","type":"page","id":103,"url":"/cover-block-spacing/","kind":"post-type","isTopLevelLink":true} /-->

<!-- wp:navigation-link {"label":"Group Border Test","type":"page","id":33,"url":"/group-border-test/","kind":"post-type","isTopLevelLink":true} /-->
<!-- /wp:navigation -->

This markup includes opensInNewTab and title in the navigation-link blocks. With these, the missing attributes are rendered correctly:

image

So I'm guessing this is a GB issue with the way it renders a menu either specified by location or whenever a menu is rendered with only the <!-- wp:navigation ... markup on its own. I'd appreciate someone else taking a look too in case I've misunderstood!

@danieldudzic
Copy link
Contributor

@mikachan I have tested this with Tove and the blank target link works fine. I have no idea what in Blockbase might be causing this, though.

@mikachan
Copy link
Member

Ah OK. I've just tried with Tove too but it looks like that theme doesn't register any menu locations. This means when you go to add the menu to the header, you have to manually add the menu items in the block editor, which means it adds each navigation-link block individually with the opensInNewTab etc attributes as above (with individual wp:navigation-link blocks with all the required attributes).

I've also tried this with Mebae, which adds the menu exactly the same as Blockbase. That includes just the wp:navigation block with "__unstableLocation":"primary". There is a primary menu location registered with register_nav_menus(). This doesn't add the target or title attributes on the front end either, which is what makes me think it's a GB issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants