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

Abierto
#4,702 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
72/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
javascript, typescript
Área
frontend

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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

Lenguaje dominante
TypeScript
Estrellas
36.2k
Forks
1.1k
Merge medio
9 h
PR fusionados (30 d)
463

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de solidjs/solid

Todos los issues de solidjs/solid

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.