Skip to content

gsx: error when a templ body has more than one top-level element #169

Closed

Description

@grindlemire

A templ whose body has two top-level elements compiles without complaint, but only the first one is returned from Render. The rest are still generated, so a <modal> placed after the closing tag of the root <div> mounts itself, registers as an overlay and draws on screen, yet it never joins the element tree. Its buttons never receive focus, and Enter, Escape, Tab and clicks all do nothing.

Three guide snippets shipped with exactly this shape (guide 09, fixed in #168, and two places in guide 06) and tui check passed all of them.

The analyzer should report an error when a component body contains more than one top-level Element, ComponentCall, ComponentExpr, ForLoop or IfStmt, anchored at the second one, with a hint to wrap them in a single root element. Top-level LetBinding and GoCode nodes are fine and should not count.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions