Controlled input keeps text that onChange rejected (no setState)
維護者通常 1 天內回覆
@bilalvur 已經在處理了。
開始於 2026年10月30日。
評估
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 新手友好度
- 55/100
- Issue 類型
- 缺陷
- 描述清晰度
- 基本清楚
- 活躍度
- 活躍
- 技術堆疊
- playwright, react, typescript, vite
- 領域
- frontend
研究方向
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.
由索引模型根據 Issue 內容生成。
描述
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.
- 主要語言
- TypeScript
- 星號
- 581
- 分支
- 28
- 平均合併
- 13 小時 48 分鐘
- 30 天內合併 PR
- 45
環境準備
這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
TanStack/redact 的其他 Issue
-
難度 2/5 1-3 小時 新手友好度 84/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 85/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 1 天內回覆
-
難度 4/5 1-2 天 新手友好度 35/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 20/100
維護者通常 1 天內回覆
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 78/100
fb55/htmlparser2#2579 ·
維護者通常 1 天內回覆
-
bug good first issue needs-review
難度 1/5 1-3 小時 新手友好度 83/100
維護者通常 1 天內回覆
-
documentation public
難度 1/5 1-3 小時 新手友好度 68/100
midnightntwrk/umbradb#65 ·
維護者通常 2 天內回覆
-
area/channels kind/bug priority/medium
難度 2/5 1-3 小時 新手友好度 78/100
nanocoai/nanoclaw#4501 · 1 則留言 ·
維護者通常 1 天內回覆
-
needs verification
難度 2/5 1-3 小時 新手友好度 74/100
維護者通常 13 天內回覆