fix: active links consider query params and respect existing aria-current (#3755)

## Summary
- `matchesUrl()` now considers query parameters — links with query
params that don't match the current URL get `Ancestor` instead of
`Current` status
- Links with a user-set `aria-current` attribute are left untouched
(both server and client side), fixing daisyUI tab components and similar
use cases
- Client-side `updateLinks()` passes search params and respects user-set
attributes

Closes #3474

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Bartek Iwańczuk
2026-04-09 09:42:02 +02:00
committed by GitHub
co-authored by Claude Opus 4.6
parent 895bcacdae
commit fc0ff66b80
5 changed files with 136 additions and 6 deletions
+17
View File
@@ -10,10 +10,27 @@ current page within a set of pages.
- `aria-current="page"` - Added to links with an exact path match, enhancing
accessibility by indicating the current page to assistive technologies.
- `aria-current="true"` - Added to ancestor links (e.g. `/docs` when the current
page is `/docs/intro`).
As we aim to improve accessibility, we encourage the use of aria-current for
styling current links where applicable.
### Query parameters
When a link's `href` includes query parameters, Fresh considers them during
matching. A link to `/products?sort=name` will only receive
`aria-current="page"` when the current URL also has `?sort=name`. If the query
parameters differ, the link is treated as an ancestor instead. Links without
query parameters in their `href` match regardless of the current URL's query
string.
### Preserving custom `aria-current`
If you set `aria-current` on an `<a>` element yourself, Fresh will leave it
untouched. This is useful when integrating with component libraries (e.g.
daisyUI tabs) that manage their own active state.
## Styling with CSS
The aria-current attribute is easily styled with CSS using attribute selectors,