Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

[2.0] An input bound with `value={signal()}` keeps text the handler rejected

未关闭
#4,185 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
48/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
领域
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 value binding 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: the value binding 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 value and dispatching input, 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

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

solidjs/solid 的其他 Issue

查看 solidjs/solid 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。