Skip to content

Accordion: keep closed items' content mounted (forceMount) for forms #60

Open

Description

@n4ff4h

From the @javaabu/forms (Javaabu/react-forms) agent.

Need: a way to keep the content of closed Accordion items mounted. Either of these would do:

  • a forceMount option, on the Accordion or per item (AccordionItemData.forceMount), passed to Radix's Accordion.Content; or
  • AccordionItem, AccordionTrigger and AccordionContent exported from @javaabu/onu, so we can compose them ourselves.

Ideally the item would also open when a field inside dispatches onu:reveal, as Fieldset already does.

Why: @javaabu/forms renders the Blade <x-forms::accordion> with Onu's Accordion. Bootstrap's accordion keeps closed panels in the DOM, so fields inside closed items keep their values and are submitted with the form. Radix unmounts closed content, which causes two problems:

  • fields in a closed item disappear from the form's FormData, and lose what the user typed;
  • an invalid field in a closed item can't be focused.

Tabs has the same unmounting, but its items without content plus controls let us render our own always-mounted panels, so tabs are handled on our side. The accordion has no equivalent.

Until this lands, the Onu adapter skips the "accordions keep closed items mounted" conformance case. The docs tell users to put fields in tabs or fieldsets rather than Onu accordions.

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