[2.0] Event handlers fired synchronously from an effect (focus(), showModal()) inherit the effect's strict-read window
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 44/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- javascript, typescript
Direzione di ricerca
Start by tracing how Solid delegates DOM event handlers and manages strict-read and effect-callback state when native calls such as focus() dispatch events synchronously. Add or locate a regression test for an effect-triggered focus event whose handler reads a prop, and check the dialog showModal()/close() cases described here. Done means these handlers run with a clean reactive state, without the strict-read warning or effect-callback phase.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Version: solid-js / @solidjs/web / @solidjs/signals 2.0.0-rc.15 (the rc.16 and rc.17 changelogs don't mention it)
What happens
A native DOM call that fires events synchronously — el.focus(), dialog.showModal(), dialog.close() — made from the apply half of an effect runs the delegated handlers inside that effect callback. A handler that reads a prop (a normal thing for an event handler to do) then logs [STRICT_READ_UNTRACKED] in dev, as if the read happened in the effect body.
import { createEffect, createSignal } from 'solid-js'
function Field(props: { label: string }) {
return <input onFocus={() => console.log('focused', props.label)} />
}
export function App() {
const [open, setOpen] = createSignal(false)
let box!: HTMLDivElement
createEffect(open, (isOpen) => {
if (isOpen) box.querySelector('input')!.focus() // handler runs here
})
return (
<div ref={box}>
<Field label="Name" />
<button onClick={() => setOpen(true)}>Edit</button>
</div>
)
}
Click "Edit": the focus moves from the effect, onFocus reads props.label, and dev logs [STRICT_READ_UNTRACKED]. Focusing the same input with the mouse logs nothing.
Same with a <dialog> opened with showModal() from an effect: the focus it moves inside and the focus it gives back on close() both fire focus/blur handlers inside the effect callback.
Expected
An event handler runs from a clean reactive state no matter what dispatched the event: no strict-read window and not in the effect-callback phase, the same as for a user's own event. The handler is a one-time snapshot by nature; where the dispatch came from shouldn't change that.
Workaround
We wrap each such native call in untrack(() => el.focus()), which ends the strict-read window for the handlers it fires (the effect-callback phase itself stays, so a computation created in such a handler has no owner).
- Lingua principale
- TypeScript
- Stelle
- 36.2k
- Fork
- 1.1k
- Merge medio
- 10h 34m
- PR unite (30g)
- 364
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi 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
-
`lazy()`: remounting an already-loaded component renders empty (or the Suspense fallback) since 1.9.14Forse già presa @itisrmk l’ha presa 6 giorni fa. Aperta1.x
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
I maintainer di solito rispondono entro 1 giorno
-
enhancement
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
I maintainer di solito rispondono entro 1 giorno
-
`createRoot`'s dispose function keeps `fn` alive, so `<For>`/`<Index>` rows retain removed list itemsForse già presa @boombang l’ha presa 8 giorni fa. Aperta1.x
Difficoltà 4/5 1-2 giorni Idoneità per principianti 45/100
I maintainer di solito rispondono entro 1 giorno
-
enhancement
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
I maintainer di solito rispondono entro 1 giorno
-
Per-scope takeover for live nodes whose server value is still streaming (D8 follow-up to #3817)Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di solidjs/solid
Issue simili
-
level/task type/bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
wazuh/wazuh-dashboard-plugins#9508 ·
I maintainer di solito rispondono entro 1 giorno
-
Testnet EOL page links Zonescan mainnetForse già presa @napelvs l’ha presa oggi. Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 76/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
Azure-Samples/azure-search-openai-demo#3249 ·
I maintainer di solito rispondono entro 1 giorno
-
[Docs] docs/architecture.mermaid leaves out 21 of the 51 src/ directoriesForse già presa @uyg7x l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
I maintainer di solito rispondono entro 1 giorno
-
enhancement status:needs-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
dongdongbh/Mindwtr#1438 ·
I maintainer di solito rispondono entro 1 giorno