You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The problem is that all 3 links cannot be active here at the same time and aria-current fails to differentiate this difference. The workaround here would be to build a custom A that also takes into account the search params.
Search query parameters are tricky in that they aren't generally mutually exclusive. I see in this example using the same query paramter they are. But speaking more generally under what conditions do they match or not match? Is it if it is a complete match? Do you do it on partial matches? I wasn't sure so never implemented it. I'm gathering partial matching would be considered the same? Maybe it needs to be configurable by option? I'd be interested in prior art here.
I checked against tanstack router and it has several options to help support this https://tanstack.com/router/latest/docs/framework/react/guide/navigation#active-options. It defaults to specifically checking the search and every property defined in the search object must match. If you want to explicitly exclude props from triggering the active state if it is a partial match you must use explicitUndefined and mark the prop as undefined in the search object.
TLDR: Search works OOTB intuitively and you blacklist props you want to prevent from being considered a match.
Activity
ryansolid commentedon Mar 3, 2025
Search query parameters are tricky in that they aren't generally mutually exclusive. I see in this example using the same query paramter they are. But speaking more generally under what conditions do they match or not match? Is it if it is a complete match? Do you do it on partial matches? I wasn't sure so never implemented it. I'm gathering partial matching would be considered the same? Maybe it needs to be configurable by option? I'd be interested in prior art here.
Akkuma commentedon Mar 3, 2025
I checked against tanstack router and it has several options to help support this https://tanstack.com/router/latest/docs/framework/react/guide/navigation#active-options. It defaults to specifically checking the search and every property defined in the search object must match. If you want to explicitly exclude props from triggering the active state if it is a partial match you must use
explicitUndefinedand mark the prop asundefinedin the search object.TLDR: Search works OOTB intuitively and you blacklist props you want to prevent from being considered a match.
Demo: https://stackblitz.com/edit/tanstack-router-rhftaozp?file=src%2Fmain.tsx