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

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

Đang mở
#626 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

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
45/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
elixir
Lĩnh vực
frontend

Hướng nghiên cứu

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.

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

Mô tả

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

Ngôn ngữ chính
Elixir
Star
2.1k
Fork
146
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

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

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

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 surface-ui/surface

Tất cả issue của surface-ui/surface

Issue tương tự

Thêm issue về Elixir

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.