Closed Megafry closed 1 year ago
Is there any reason why node.active
is not suitable for your needs? I’m not sure what difference an active and current node is-
The active mode will be determined if the url you’re currently on matches the url of the node.
Hi Josh
Thanks for your replay, the status current
should indicate the page that the user is currently on.
Highlighting the current page differently is often necessary, especially with mega menus.
To set the right aria-current
state would be greatly simplified. aria-current - MDN Web Docs
For the following URL page-a/page-a2
active
aria-current="location"
active
current
aria-current="page"
best regards
Right, I suppose I see what you mean. In the case of a nested structure, we will mark parent nodes as active if a child is. Commonly for visual purposes to show an active state (your in Page A + Page A2). good call on aria-current
, i actually wasn't aware of this.
You can use node.getActive(false)
to not include children-active checks, which will effectively tell you if you're on that current node.
I'll also add a node.getCurrent()
which adds the aria-current
attribute to the render()
call.
To get this early, run composer require verbb/navigation:"dev-craft-4 as 2.0.19"
.
Added in 2.0.20
What are you trying to do?
To Know if a node is the current one, I need to first make a query with help of
getActiveNode
.What's your proposed solution?
Add a new attribute
current
to all nodes identical toactive
.Additional context
Did I miss something in the documentation?