surface-ui / surface

A server-side rendering component library for Phoenix
https://surface-ui.org
MIT License
2.08k stars 150 forks source link

Surface LiveComponent raise single static root error if render root is Form Component #746

Closed Dylan-aidkr closed 6 months ago

Dylan-aidkr commented 6 months ago

Describe the bug

if i use Form component in Surface Live Component, it raises 'Stateful components must have a single static HTML tag at the root' error

How to reproduce it

use MyWeb, :surface_live_component

def render(assigns) do
    ~F"""
    <Form class={["form-table-row"]}>
      <div>
        hello
      </div>
    </Form>
    """
end

Your Environment

Surface: v0.11.4 LiveView: v0.20.14 Elixir: v1.15.5 (compiled with Erlang/OTP 26)

dougw-bc commented 6 months ago

You need a static node at the root of a live component, like a div

~F"""
 <div>
  <Form class={["form-table-row"]}>
    <div> hello </div>
  </Form>
 </div>
"""

Unrelated, but Form is being deprecated, so might want to write new code without it, and just use the phoenix form/1 component.

Dylan-aidkr commented 6 months ago

I misunderstood the meaning of static node until now. for some styling requirements, I couldn't simply wrap it with a div. I will try phoenix form/1 instead. Thank you for the answer.