updates to a Input's disabled property causes the value property to reset

Đang mở
#4,702 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ó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
72/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 reproducing the behavior in the linked Solid playground, comparing the four input cases when you edit their values and toggle disabled. Then trace how Solid updates input properties in its DOM rendering code and find the relevant tests. Done means toggling disabled does not reset an edited value when value is reactive, with the other cases still behaving as expected.

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

Mô tả

When both the disabled and value property of an input are signals, changes to the disabled property causes the value to reset to its initial value even after being modified.

Is this expected behavior?

Below is both code and a playground link. Just change the values in the four boxes and then click "CLICK ME".

https://playground.solidjs.com/MattLysinger/6fabf761-9664-462b-a96e-2e5f82c3b3f3

import { render } from "@solidjs/web";
import { createSignal } from "solid-js";

function Counter() {
  let ref1!: HTMLInputElement;
  let ref2!: HTMLInputElement;
  const [disabled, setDisabled] = createSignal(false);
  const [value, setValue] = createSignal(11);

  return (
    <>
      <button
        type="button"
        onClick={() => {
          setDisabled((x) => !x);
          ref1.disabled = !ref1.disabled;
          ref2.disabled = !ref2.disabled;
        }}
      >
        CLICK ME
      </button>
      
      <p>1. disabled & value are both signals and the disabled signal is toggled</p>
      <input disabled={disabled()} type="number" value={value()} />
      
      <p>2. disabled is a signal and value is a number and the disabled signal is toggled</p>
      <input disabled={disabled()} type="number" value={11} />
      
      <p>3. value is a signal and the disabled property is directly toggled</p>
      <input ref={ref1} type="number" value={value()} />
      
      <p>4. value is a number and the disabled signal is directly toggled</p>
      <input ref={ref2} type="number" value={11} />
    </>
  );
}

render(() => <Counter />, document.getElementById("app")!);

Originally posted by @MattLysinger in https://github.com/solidjs/solid/discussions/4496

Ngôn ngữ chính
TypeScript
Star
36.2k
Fork
1.1k
Merge trung bình
9 giờ
Pull request đã merge (30 ngày)
463

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.