Controlled input keeps text that onChange rejected (no setState)
Mantenedores costumam responder em até 1 dia
@bilalvur já está trabalhando nisso.
Desde 30/10/2026.
Avaliação
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Facilidade para iniciantes
- 55/100
- Tipo de issue
- Bug
- Clareza
- Razoavelmente clara
- Status de atividade
- Ativa
- Stack de tecnologia
- playwright, react, typescript, vite
- Domínio
- frontend
Direção de pesquisa
Start by tracing how Redact handles controlled input values and change events; compare that path with React using the supplied main.js reproduction. Build and preview with Vite, then type 1a2 and confirm the input displays 12 when onChange rejects the change. The issue names no repository source files or tests, so locate the relevant implementation and regression test first.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
What happens
A controlled input whose onChange rejects a change by not calling setState keeps the typed text. React writes the controlled value back after the event, so the input never shows rejected text. Redact leaves it in the DOM, out of sync with state.
Typing 1a2 into the input below:
- React 19.3.1:
12 - Redact 0.2.3:
1a2
Same result in Chromium 156, Firefox 157 and WebKit 27.2 (Playwright 1.64.1, production build). Redact 0.1.4, 0.1.5, 0.2.0 and 0.2.1 behave the same, so it is not a 0.2 regression. #64 is also about controlled text inputs, but a different symptom.
We hit it in a form field that ignores input not starting with a number.
Reproduction
package.json
{
"name": "redact-controlled-input-repro",
"private": true,
"type": "module",
"scripts": {
"build": "vite build",
"preview": "vite preview --host 127.0.0.1"
},
"dependencies": {
"@tanstack/redact": "0.2.3",
"react": "19.3.1",
"react-dom": "19.3.1"
},
"devDependencies": {
"vite": "8.3.4"
}
}
index.html
<!doctype html>
<html lang="en">
<head><meta charset="utf-8"><title>Controlled input reproduction</title></head>
<body><div id="root"></div><script type="module" src="/main.js"></script></body>
</html>
vite.config.js
import { redact } from '@tanstack/redact/vite'
import { defineConfig } from 'vite'
export default defineConfig({
plugins: process.env.NO_REDACT ? [] : [redact()],
})
main.js
import { createElement, useState } from 'react'
import { createRoot } from 'react-dom/client'
function Digits() {
const [value, setValue] = useState('')
return createElement('input', {
value,
onChange: (event) => {
if (/^\d*$/.test(event.target.value)) setValue(event.target.value)
},
})
}
createRoot(document.getElementById('root')).render(createElement(Digits))
Run npm install && npm run build && npm run preview, then type 1a2. With NO_REDACT=1 npm run build it shows 12.
I used Claude Code to narrow this down from our app and to run the repro across browsers and versions.
- Linguagem predominante
- TypeScript
- Estrelas
- 581
- Forks
- 28
- Merge médio
- 13h 48min
- PRs com merge (30d)
- 45
Preparar o ambiente
Este projeto não oferece contêiner de desenvolvimento, Dockerfile nem guia de contribuição, então a configuração fica por sua conta: comece pelo README e veja nosso guia da primeira contribuição para os passos gerais.
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de TanStack/redact
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 84/100
TanStack/redact#142 · 4 comentários ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 85/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 4/5 1-2 dias Facilidade para iniciantes 35/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 20/100
Mantenedores costumam responder em até 1 dia
Todas as issues de TanStack/redact
Issues semelhantes
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
fb55/htmlparser2#2579 ·
Mantenedores costumam responder em até 1 dia
-
bug good first issue needs-review
Dificuldade 1/5 1-3 horas Facilidade para iniciantes 83/100
Mantenedores costumam responder em até 1 dia
-
Add Module DB RulesAbertadocumentation public
Dificuldade 1/5 1-3 horas Facilidade para iniciantes 68/100
midnightntwrk/umbradb#65 ·
Mantenedores costumam responder em até 2 dias
-
area/channels kind/bug priority/medium
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
nanocoai/nanoclaw#4501 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
needs verification
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 74/100
Mantenedores costumam responder em até 13 dias