A removed input's onBlur runs during the commit that removes it (Chrome)
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 30/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- react, typescript
- Área
- frontend
Línea de trabajo
Start with commitBeforeMutationEffects and dispatchEvent in the event-system code, which show why Redact's listener runs while React's does not, then look at commitMutation where the proposed depth counter would go. The branch linked in the issue has a fix and tests in tests/deleted-element-events.test.tsx, so reviewing it or running the browser suite via scripts/actions-browser.config.mjs is the practical entry point. Done means the removed-input blur case no longer fires onBlur in Chrome, and the layout-effect blur still dispatches.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Chrome fires blur on a focused element just before removing it from the DOM. When a Redact commit removes a focused input, Redact runs that input's onBlur mid-commit, with the props of a view the user just closed. If the handler sets state, it can undo the update that removed it.
React never calls it. commitBeforeMutationEffects turns its event system off (_enabled = false) until the mutations finish, and dispatchEvent returns early while it is off (react-dom-client.development.js in react-dom 19.3.1).
function Form() {
const [open, setOpen] = useState(true)
if (!open) return <p>closed</p>
return (
<div>
<input onBlur={() => console.log('blur')} />
<button onMouseDown={e => e.preventDefault()} onClick={() => setOpen(false)}>Done</button>
</div>
)
}
Focus the input and click Done in Chrome. React 19.3.1 logs nothing. Redact on main logs blur.
We hit it in a sheet whose field marks itself touched on blur: confirming the sheet removed the field, its onBlur ran, and the sheet reopened the form.
Fix
Branch with the fix and tests, ready to merge (I can't open a PR here): https://github.com/TanStack/redact/compare/main...WolfieLeader:redact:fix/skip-events-on-deleted-elements
What changes
commitMutationruns the mutation queue and placements insiderunMutations, which raises a depth counter.- Redact's event listener returns early while the counter is above zero.
- Effects, refs and
autoFocusrun after the mutations, so their focus events still dispatch, as in React.
Testing
tests/deleted-element-events.test.tsxhas two cases: a click that removes a focused input, and a layout-effect cleanup that blurs an input being removed. The first needs Chrome's removal blur, so it only proves something in the browser run; I added the file toscripts/actions-browser.config.mjs.- Both fail on
mainand pass with the fix, in jsdom and in Chrome. React 19.3.1 passes both in Chrome. onFocusfromautoFocusand fromfocus()inuseLayoutEffectstill fire, as in React.pnpm test:cipasses on Node 24.22.0.redact/dom-clientgrows 27 B gzip, within budget.- Not run: the Firefox and WebKit browser jobs.
scripts/test-react-compatibility-size.mjsfails locally on unchangedmain(server/index+67 B), so I left that check to CI.
- Lenguaje dominante
- TypeScript
- Estrellas
- 640
- Forks
- 32
- Merge medio
- 1 h 15 min
- PR fusionados (30 d)
- 7
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de TanStack/redact
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
TanStack/redact#195 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
TanStack/redact#142 · 4 comentarios ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
Todos los issues de TanStack/redact
Issues similares
-
bug data-types
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
ClickHouse/clickhouse-js#1293 ·
Los mantenedores suelen responder en 1 día
-
area: middleware enhancement good first issue
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
-
agent/quality testing
Dificultad 1/5 Menos de una hora Aptitud para principiantes 95/100
Los mantenedores suelen responder en 1 día
-
GitHub registry install via `gh` credentials rewrites `\u0000`–`\u001f` escapes in source files to `^@`–`^_`Posiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 92/100
Los mantenedores suelen responder en 2 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
juspay/agent-distro#203 ·
Los mantenedores suelen responder en 1 día