Active links: a query-less link stays aria-current="page" after navigating to the same path with a query (two current links)
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 76/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- deno, typescript
- Ambito
- accessibility, frontend
Direzione di ricerca
Parti da matchesUrl() in packages/fresh/src/runtime/shared_internal.ts, che è l'unico punto in cui viene deciso il confronto; il chiamante lato client è updateLinks() in packages/fresh/src/runtime/client/partials.ts, e il passaggio lato server usa lo stesso helper, quindi una sola correzione copre entrambi. Leggi come vengono derivati needleSearch/currentSearch (mancante vs stringa vuota) prima di cambiare il branch, poi fai restituire Current ai percorsi uguali solo quando le ricerche coincidono e decidi se un link senza query ricade su Ancestor o None come suggerisce l'issue. Riproduci con l'esempio della tab /list, e verifica che sia fatto confermando che solo /list?tab=open porta aria-current="page" sia in una navigazione client sia in un caricamento diretto, con i test esistenti sui active-link ancora superati.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Summary
After a client navigation to a URL that has a query (/list?tab=open), a link to the same path without a query (/list) is still marked aria-current="page", so two links claim to be the current page. The server-side active-link pass has the same result for a document load of /list?tab=open.
Found on Fresh 2.3.3, after #3755. Current main has the same code.
Cause
matchesUrl() (packages/fresh/src/runtime/shared_internal.ts) compares the search only when the link has one:
if (current === href) {
// If the link has query params, only mark as current if they match
if (needleSearch && currentSearch !== undefined && needleSearch !== currentSearch) {
return UrlMatchKind.Ancestor;
}
return UrlMatchKind.Current;
}
A link with no query (needleSearch === "") is therefore Current for every query on that path. updateLinks() (runtime/client/partials.ts) then sets data-current and aria-current="page" on it.
Reproducer
// routes/list.tsx
export default function List(ctx) {
const tab = ctx.url.searchParams.get("tab") ?? "all";
return (
<body f-client-nav>
<nav>
<a href="/list">All</a>
<a href="/list?tab=open">Open</a>
<a href="/list?tab=done">Done</a>
</nav>
<Partial name="list"><p>Showing: {tab}</p></Partial>
</body>
);
}
- Load
/list, then click "Open" (a client navigation). - Inspect the links: both
<a href="/list">and<a href="/list?tab=open">carryaria-current="page"anddata-current="true". - Loading
/list?tab=opendirectly gives the same two current links (server pass).
Expected: only /list?tab=open is current. The query-less /list should not be Current when the current URL has a different, non-empty query.
The same thing happens with <a href="/list" f-partial="/partials/list"> tabs that swap one region. #3755's escape hatch (an explicit aria-current on the link) works, but it puts the burden on every app with query-driven tabs or filters.
Related observation
The same rule marks every same-path link with a different query as Ancestor, i.e. aria-current="true": row links such as /list?item=42, pager links (/list?page=2), a drawer's close link. Screen readers announce each of them as "current". These are siblings of the current URL, not ancestors, so None would fit better for a same-path link whose query differs.
Suggested fix
In matchesUrl(), when the paths are equal, return Current only if the searches are equal (treating missing and empty as equal). Otherwise return None, or Ancestor only when the link has no query, if keeping "section" highlighting for a query-less base link is a goal.
- Lingua principale
- TypeScript
- Stelle
- 13.8k
- Fork
- 757
- Merge medio
- 3m
- PR unite (30g)
- 2
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di freshframework/fresh
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 82/100
freshframework/fresh#3833 ·
-
feat
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
freshframework/fresh#3803 · 1 commento ·
-
Did you stop maintaining it?Aperta
Difficoltà 5/5 Più di una settimana Idoneità per principianti 10/100
freshframework/fresh#3918 · 1 commento · 4 reazioni ·
-
Tab title doesn't update to <Head> <title> when navigating to a page with another <title>Forse già presa @1AbdullahButt l’ha presa 8 giorni fa. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 57/100
freshframework/fresh#3916 ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 55/100
freshframework/fresh#3911 ·
Tutte le issue di freshframework/fresh
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
software-mansion/argent#1946 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 63/100
podman-desktop/podman-desktop#20216 ·
I maintainer di solito rispondono entro 1 giorno
-
[Type] Bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
WordPress/ai#1386 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 5 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
omdsh-dev/DSH-better-sidebar#1205 ·
I maintainer di solito rispondono entro 3 giorni