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: current-menu-item is missing for non-singular objects #43260

Closed
Andrew-Starr opened this issue Aug 16, 2022 · 0 comments · Fixed by #43800
Closed

Navigation: current-menu-item is missing for non-singular objects #43260

Andrew-Starr opened this issue Aug 16, 2022 · 0 comments · Fixed by #43800
Assignees
Labels
[Block] Navigation Affects the Navigation Block

Comments

@Andrew-Starr
Copy link

Description

When a Navigation Link or a Navigation Submenu is a non-singular object, the current-menu-item class is missing.

By non-singular I mean archive links such as Categories or Tags.

Step-by-step reproduction instructions

Add a Navigation block with a mix of navigation item links to Posts, Pages, Categories and Tags.

On frontend click the links to visit the "page" of each item, and notice that only Posts and Pages have the current-menu-item class in the item's markup whilst on it's "page".

"page" here refers to the current single post, single page, category archive, or tag archive.

Screenshots, screen recording, code snippet

It seems the Navigation Link and Navigation Submenu blocks are only checking the ID attribute against the current singular ID.

$is_active   = ! empty( $attributes['id'] ) && ( get_the_ID() === $attributes['id'] );

This should instead be checking against the queried object ID, similar to the way it is done in the classic nav-menu-template, like so:

$is_active   = ! empty( $attributes['id'] ) && ( get_queried_object_id() === $attributes['id'] );

Environment info

WP 6.0.1
Gutenberg 13.8.2

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

@amustaque97 amustaque97 added Needs Testing Needs further testing to be confirmed. [Block] Navigation Affects the Navigation Block labels Aug 16, 2022
@carolinan carolinan assigned carolinan and unassigned carolinan Sep 2, 2022
@github-actions github-actions bot added the [Status] In Progress Tracking issues with work in progress label Sep 2, 2022
@carolinan carolinan removed the Needs Testing Needs further testing to be confirmed. label Sep 2, 2022
@priethor priethor removed the [Status] In Progress Tracking issues with work in progress label May 17, 2023
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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants