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: add current-menu-item also for archive links #43800

Merged
merged 1 commit into from
Sep 6, 2022

Conversation

carolinan
Copy link
Contributor

@carolinan carolinan commented Sep 2, 2022

What?

Makes sure that the current-menu-item class is added to navigation links for archives, not only for single post items.
Closes #43260
Closes #43843

Props @Andrew-Starr

Why?

Thecurrent-menu-item class was missing from this type of link.

How?

The CSS class is added after a comparison between the id attribute and get_the_ID.
This pr changes get_the_ID to get_queried_object_id() to include archive pages.

Testing Instructions

Make sure that the test install has categories and tags assigned.

  1. Add a navigation block with navigation links to a single post, single page, a category archive and a tag archive.
  2. On the front of the website, visit each navigation link and confirm that the list item has the current_menu_item class when you view that page.

Screenshots or screencast

Copy link
Contributor

@cbravobernal cbravobernal left a comment

Choose a reason for hiding this comment

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

Tested and working as described.

LGTM!

@cbravobernal cbravobernal merged commit 2d1e007 into trunk Sep 6, 2022
@cbravobernal cbravobernal deleted the update/navigation-current-menu-item branch September 6, 2022 09:36
@github-actions github-actions bot added this to the Gutenberg 14.1 milestone Sep 6, 2022
@cbravobernal cbravobernal added the [Type] Bug An existing feature does not function as intended label Sep 13, 2022
BenoitZugmeyer added a commit to BenoitZugmeyer/gutenberg that referenced this pull request Sep 26, 2022
This commit applies the same fix as
WordPress#43800
but at other places where we are adding the current-menu-item class:
* in the page-list block
* in the navigation-submenu block
Mamaduka pushed a commit that referenced this pull request Sep 27, 2022
…44474)

This commit applies the same fix as #43800 but at other places where we are adding the current-menu-item class:
* in the page-list block
* in the navigation-submenu block
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 [Type] Bug An existing feature does not function as intended
Projects
None yet
2 participants