Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Input components have their value prop overwritten in form context if it is nil

Aperta
#626 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
45/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
elixir
Ambito
frontend

Direzione di ricerca

Start with Surface.Components.Form.HiddenInput and the Form/Field handling shown in the reproduction, then run the nested MyComponent example against a changeset. Trace how a nil value prop is resolved in the form context; done means an explicit nil remains effective instead of being replaced by the matching changeset value.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Describe the bug

Suppose you've got a component that uses a Surface input component:

defmodule MyComponent do
  use Surface.LiveComponent

  data value, :string, default: nil

  def render(assigns) do
    ~F"""
    <Surface.Components.Form.HiddenInput value={@value} />
    """
  end
end

Now, if the component is used inside a Surface form context with the form having a changeset, as here:

defmodule MyForm do
  Surface.LiveComponent

  data changeset, :changeset, (some changeset value)

  def render(assigns)
    ~F"""
    <Form for={@changeset}>
      <Field name="my_field">
        <MyComponent />
      </Field>
    </Form>
    """
  end
end

Then the changeset's value always overrides the nested matching form field value in case if the data 'value' field managed by the stateful component of MyComponent is nil.

The behavior you expected

I should be able to set value prop of the input component explicitely as nil.

Your Environment

Surface: v0.7.4
LiveView: v0.17.10
Elixir: v1.13.4

Lingua principale
Elixir
Stelle
2.1k
Fork
146
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di surface-ui/surface

Tutte le issue di surface-ui/surface

Issue simili

Altre issue su Elixir

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.