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

オープン
#4,702 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
72/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
javascript, typescript
領域
frontend

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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

主要言語
TypeScript
スター
36.2k
フォーク
1.1k
平均マージ
9時間
マージ済み PR(30日)
463

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

solidjs/solid のほかの issue

solidjs/solid の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。