gutenberg icon indicating copy to clipboard operation
gutenberg copied to clipboard

Navigation Submenu: Parent dropdown arrow and submenu container visible on viewports where all children are hidden

Open BugReportOnWeb opened this issue 6 months ago • 3 comments

Description

This was originally reported on WordPress Core Trac ticket here: https://core.trac.wordpress.org/ticket/64835

When all child items of a core/navigation-submenu block are hidden on a specific viewport block, the parent item still renders its dropdown arrow and submenu container on that viewport.

On further check, it looks like items hidden via "Hide on Desktop/Tablet/Mobile" still emit their full HTML and the hiding is handled purely by CSS via wp-block-hidden-* classes on the child <li>. So $inner_blocks_html is never empty, and $has_submenu is always true regardless of visibility settings.

https://github.com/WordPress/gutenberg/blob/23f840960ebf80b59832a0d724fa1c018e79a186/packages/block-library/src/navigation-submenu/index.php#L89-L93

Step-by-step reproduction instructions

  1. Create a page with a Navigation block
  2. Add a submenu parent item
  3. Add one or more child links inside it
  4. For each child, click on three dots for block settings > Hide > select all viewport options.
  5. Save and preview on the front end

Expected: The parent item renders as a plain link with no dropdown arrow and no submenu container, since there are no visible children on any viewport.

Actual: The parent item still shows a dropdown arrow and renders an empty submenu container

Screenshots, screen recording, code snippet

Image

Environment info

  • WordPress: 7.1-alpha-62201
  • PHP: 8.3.30
  • Server: Apache/2.4.66 (Debian)
  • Database: mysqli (Server: 11.8.6-MariaDB-ubu2404 / Client: mysqlnd 8.3.30)
  • Browser: Chrome 146.0.0.0
  • OS: macOS
  • Theme: Twenty Twenty-Five 1.4
  • MU Plugins: None activated
  • Plugins:
    • Gutenberg 23.1.0-rc.1
    • Test Reports 1.2.1

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

  • [x] Yes

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

  • [x] Yes

Please confirm which theme type you used for testing.

  • [x] Block
  • [ ] Classic
  • [ ] Hybrid (e.g. classic with theme.json)
  • [ ] Not sure

BugReportOnWeb avatar May 11 '26 09:05 BugReportOnWeb

I'm closing this issue per @jeryj's comment on the PR.

youknowriad avatar Aug 27 '26 13:08 youknowriad

I think it's still a valid issue - I just wasn't sure about the fix in #78148. Should we reopen this?

jeryj avatar Aug 27 '26 13:08 jeryj

I thought you said, it's too edge casy. I'm fine either way, your call.

youknowriad avatar Aug 27 '26 14:08 youknowriad