Skip to content

Navigation Block: Flip submenu indicator icon on submenu expansion #70307

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

Conversation

shrivastavanolo
Copy link
Contributor

@shrivastavanolo shrivastavanolo commented Jun 4, 2025

What?

Closes #35636

Why?

Currently, opening a submenu does not change the downward arrow icon. Ideally, the icon should flip upward to indicate the submenu is expanded.

How?

When a submenu is expanded (aria-expanded="true"), the downward arrow icon now flips upward using a transform: scaleY(-1) CSS rule.
This change was added to packages/block-library/src/navigation/style.scss and enhances the user experience by providing a clearer visual cue of the submenu's open state.

Testing Instructions

  • Open a post or page in the editor.
  • Insert a Navigation block.
  • Add a menu item with a submenu (child items).
  • Click the parent menu item to open the submenu.
  • Observe the arrow icon. It should flip upward when the submenu is open and return to downward when closed.

Screenshots or screencast

Before
https://github.com/user-attachments/assets/a19abfbe-0145-4bd7-87c8-b6e12549b351

After
https://github.com/user-attachments/assets/e39ba6d5-780b-413a-994e-393f051e3a11

Copy link

github-actions bot commented Jun 4, 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.

Unlinked Accounts

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

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: shreyashrivastava@192.168.1.12.

Co-authored-by: shrivastavanolo <shreya0shrivastava@git.wordpress.org>
Co-authored-by: fabiankaegy <fabiankaegy@git.wordpress.org>
Co-authored-by: karmatosed <karmatosed@git.wordpress.org>
Co-authored-by: jacobcassidy <jacobcassidy@git.wordpress.org>

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

@github-actions github-actions bot added the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label Jun 4, 2025
Copy link

github-actions bot commented Jun 4, 2025

👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @shrivastavanolo! In case you missed it, we'd love to have you join us in our Slack community.

If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information.

@t-hamano t-hamano added Needs Design Feedback Needs general design feedback. [Block] Navigation Affects the Navigation Block labels Jun 4, 2025
@karmatosed karmatosed added the [Type] Enhancement A suggestion for improvement. label Jun 5, 2025
@@ -312,6 +312,11 @@ button.wp-block-navigation-item__content {
cursor: pointer;
}

// Flip submenu arrow icon when expanded.
.wp-block-navigation-submenu__toggle[aria-expanded="true"] {
transform: scaleY(-1);
Copy link
Member

Choose a reason for hiding this comment

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

@shrivastavanolo I'm curious, is there any reason you are using scaleY instead of ´rotate´?

I agree that this is a better experience and that we should include this in the plugin but I'd love to know why you went with scaleY :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hey @fabiankaegy

I used scaleY(-1) instead of rotate(180deg) or rotateX(180deg) because it just 2D flips the arrow vertically without messing with the layout. rotate(180deg) also flips it horizontally, which we don't need here, and rotateX(180deg) is a 3D transform which isn't needed here.

Since the arrow svg is symmetrical horizontally, all of them look the same visually but scaleY(-1) is the simpler and more reliable way to do it in my opinion.

Thanks for the review. Please let me know if I'm missing something here!

refs: https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/scaleY

Copy link
Member

Choose a reason for hiding this comment

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

Thanks so much :) Approved from my end!

@karmatosed karmatosed added the props-bot Adding this label triggers the Props Bot workflow for a PR. label Jun 5, 2025
@github-actions github-actions bot removed the props-bot Adding this label triggers the Props Bot workflow for a PR. label Jun 5, 2025
@karmatosed karmatosed merged commit 78b3108 into WordPress:trunk Jun 5, 2025
76 of 81 checks passed
@github-actions github-actions bot added this to the Gutenberg 21.1 milestone Jun 5, 2025
@karmatosed karmatosed self-requested a review June 5, 2025 10:02
@t-hamano
Copy link
Contributor

t-hamano commented Jun 5, 2025

Unfortunately, this PR introduces at least two visual issues. Let’s fix this issue before this PR is released as a Gutenberg plugin.

  1. When the "Open on click" is enabled, the text will be inverted.

image

  1. The nested menu arrows are not inverted correctly (or should they be?).
aa21199aab8b1ceee38a53972bd20834.mp4

@fabiankaegy
Copy link
Member

Thanks @t-hamano :) I just created a follow up PR here: #70334

t-hamano added a commit that referenced this pull request Jun 14, 2025
t-hamano added a commit that referenced this pull request Jun 16, 2025
…70427)

This reverts commit 78b3108.

Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Co-authored-by: fabiankaegy <fabiankaegy@git.wordpress.org>
chriszarate pushed a commit to chriszarate/gutenberg that referenced this pull request Jul 1, 2025
Unlinked contributors: shreyashrivastava@192.168.1.12.

Co-authored-by: shrivastavanolo <shreya0shrivastava@git.wordpress.org>
Co-authored-by: fabiankaegy <fabiankaegy@git.wordpress.org>
Co-authored-by: karmatosed <karmatosed@git.wordpress.org>
Co-authored-by: jacobcassidy <jacobcassidy@git.wordpress.org>
chriszarate pushed a commit to chriszarate/gutenberg that referenced this pull request Jul 1, 2025
…0307)" (WordPress#70427)

This reverts commit 78b3108.

Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Co-authored-by: fabiankaegy <fabiankaegy@git.wordpress.org>
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 First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository Needs Design Feedback Needs general design feedback. [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Navigation Block: Flip submenu indicator arrow icon on click/hover
4 participants