Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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

Đã đóng
#4,185 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
48/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
javascript, typescript
Lĩnh vực
frontend

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.
Ngôn ngữ chính
TypeScript
Star
36.2k
Fork
1.1k
Merge trung bình
11 giờ
Pull request đã merge (30 ngày)
343

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của solidjs/solid

Tất cả issue của solidjs/solid

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.