[2.0] An input bound with `value={signal()}` keeps text the handler rejected
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 48/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- javascript, typescript
- 领域
- frontend
调研方向
Start by locating the value binding implementation and its tests in Solid's web package; the issue provides a jsdom reproduction using @solidjs/web. Check how the binding updates the DOM when an input handler leaves the signal unchanged, and compare that behavior with the reported unrelated-update case. Done means the rejected or truncated text reconciles with the bound state without reintroducing the unrelated-update behavior.
由索引模型根据 Issue 内容生成。
描述
Describe the bug
With <input value={v()} onInput={…}>, if the handler filters or truncates the input and the state ends up unchanged, the DOM keeps the text the user typed. The value binding only rewrites the input when its effect re-runs, so a rejected keystroke never reverts. React's controlled inputs revert to the state value.
Your Example Website or App
Minimal repro inline below (@solidjs/web, jsdom).
Steps to Reproduce the Bug or Issue
const [d, setD] = createSignal("");
const [s, setS] = createSignal("");
render(() => (
<>
<input id="a" value={d()} onInput={e => setD(e.currentTarget.value.replace(/[^0-9]/g, ""))} />
<input id="b" value={s()} onInput={e => setS(e.currentTarget.value.slice(0, 3))} />
</>
), container);
// simulate typing: input.value = text; input.dispatchEvent(new Event("input", { bubbles: true })); flush();
| Typed | State | DOM |
|---|---|---|
1 |
1 |
1 |
1a |
1 |
1a |
1a2 |
12 |
12 (state changed, so it's rewritten) |
abc (max 3) |
abc |
abc |
abcd (max 3) |
abc |
abcd |
Expected behavior
Either:
- after the handler runs, the DOM value is reconciled with the bound value even if the signal didn't change; or
- there's a documented pattern or primitive for controlled inputs.
Today's workaround is writing e.currentTarget.value = d() back by hand in the handler.
Screenshots or Videos
No response
Platform
- OS: macOS (Darwin 25.5)
- Browser: n/a (reproduced in Node v24.18.0 with vitest, importing source)
- Version: solid
next@ b0ad1df50 (2026-10-20, after 2.0.0-rc.16)
Additional context
- A common React pattern: number-only fields, max length and input masks.
- The converse problem also happens: OpenClaw found that a
valuebinding rewrites the input whenever its compiled effect re-runs, even with an equal value. For example, when it's grouped with other reactive attributes or read through a spread props object, unrelated updates wiped uncommitted text (https://github.com/openclaw/openclaw/blob/1989e3dc436/.agents/skills/solid/references/lessons.md#L9). Both point to the same root cause: thevaluebinding syncs the DOM when its effect runs, rather than by comparing the DOM against the bound value. - Not yet checked in a real browser: jsdom simulates typing by setting
valueand dispatchinginput, which mirrors what the browser does, but I haven't confirmed it in a real browser.
- 主要语言
- TypeScript
- 星标
- 36.1k
- 派生
- 1.1k
- 平均合并
- 11 小时 42 分钟
- 30 天内合并 PR
- 350
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
solidjs/solid 的其他 Issue
-
`lazy()`: remounting an already-loaded component renders empty (or the Suspense fallback) since 1.9.14可能已有人在做 @itisrmk 于 4 天前认领。 未关闭1.x
难度 2/5 1-3 小时 新手友好度 62/100
维护者通常 1 天内回复
-
[2.0] Effects re-run (and run cleanup) when the compute returns an equal value; there's no `equals` option可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 4/5 3-5 天 新手友好度 54/100
维护者通常 1 天内回复
-
[2.0] The MIGRATION.md replacement for `from()` keeps the upstream subscription after dispose; add a subscription helper可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 5/5 一周以上 新手友好度 35/100
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 56/100
维护者通常 1 天内回复
-
[compiler] A valueless `prop:` attribute is dropped silently by both compilers可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 4/5 3-5 天 新手友好度 45/100
维护者通常 1 天内回复
相似的 Issue
-
ready-for-agent
难度 2/5 1-3 小时 新手友好度 68/100
xavxyz/bei-shan-lin-shui#57 ·
维护者通常 1 天内回复
-
[BUG] rag: sentence content can cross the reported sentence boundaries可能已有人在做 @LJK-ikun 今天认领。 未关闭bug
难度 2/5 1-3 小时 新手友好度 75/100
维护者通常 1 天内回复
-
bug needs-triage
难度 2/5 1-3 小时 新手友好度 70/100
维护者通常 1 天内回复
-
README: the Resource URI Schemas example's file://documents/* pattern only matches that literal URI未关闭
难度 1/5 1 小时以内 新手友好度 88/100
platformatic/mcp#361 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 65/100
siyuan-note/siyuan#20799 · 7 条评论 ·
维护者通常 1 天内回复