Link click handling breaks the <Router> isolation/context principle
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 45/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- typescript
Direzione di ricerca
Riproduci il problema nel CodeSandbox collegato con due istanze di Router, quindi esamina la gestione dei clic a livello di documento del componente A e il percorso di contesto/integrazione di Router. Conferma che i clic all'interno di ciascun Router chiamino il setter di integrazione di quel Router e verifica il comportamento rispetto ai passaggi di riproduzione elencati.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Describe the bug
I'm making the assumption here that this package supports multiple routers running at the same time as it does use context for isolation instead of some kind of global store. Described bug is not an issue if my assumption is wrong.
Router component provides context which isolates and enforces the scope of router functionality.
For example useLocation under <Router> returns the location for that particular router.
Link click handling (A component) breaks that principle and functionality because link click event handler is added to document and if you have multiple routers (with default integration or custom), only one integration setter will be always called.
I propose to handle it in some sort of scoped way, for example:
<Router scopeEl={htmlElementRef} source={integration}> and
const target = args.scopeEl || document;
target .addEventListener("click", handleAnchorClick);
Or a bit more advanced (and potentially buggy): automatically find the nearest parent HTML element for <Router>.
Your Example Website or App
https://codesandbox.io/s/solid-app-router-example-forked-25ysls?file=/Index.js
Steps to Reproduce the Bug or Issue
- Go to Home (
/) if not already there and open console - Click on any of the "Post X (modal)" links
- Clear console log
- Click on any of the "Post X (modal)" links in modal (links under router 2)
You can see in logs [router 1] set global loc: that even though this link is rendered under second <Router>, it will still invoke the setter for first <Router> integration.
Expected behavior
Link behaviour respects the context.
Link rendered under <Router1 source={integration1}> should invoke the integration1 setter.
Link rendered under <Router2 source={integration2}> should invoke the integration2 setter.
Screenshots or Videos
No response
Platform
- OS: any
- Browser: any
- Version: 0.8.3
Additional context
No response
- Lingua principale
- TypeScript
- Stelle
- 1.3k
- Fork
- 180
- Merge medio
- 1g 10h
- PR unite (30g)
- 19
Guida per i contributori
Apri la guida per i contributori
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 solidjs/solid-router
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
solidjs/solid-router#605 · 1 commento ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 65/100
solidjs/solid-router#615 ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 78/100
solidjs/solid-router#603 · 1 commento ·
-
<A> costs ~6us of server CPU per instance during SSR (20x a plain <a>), mostly mergeProps/splitProps Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 55/100
solidjs/solid-router#583 ·
-
enhancement
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
solidjs/solid-router#569 · 3 commenti ·
Tutte le issue di solidjs/solid-router
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
bcgov/bc-wallet-mobile#4761 · 1 commento ·
-
external-issue to-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
-
area-deployment area-integrations triage:bot-seen
Difficoltà 2/5 Mezza giornata Idoneità per principianti 86/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
-
refactor
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100