[Feature] Add Sheet initial open state
Summary
Adds an open: keyword to RubyUI::Sheet so a Sheet can render already open on the initial response — no SheetTrigger click required.
Sheet(open: true) do
SheetContent(class: "sm:max-w-sm") do
# ...
end
end
Why
When a Sheet is rendered as the result of a Turbo Stream (or any server-driven render where the user did not click a trigger), there is no SheetTrigger in scope to open it. Today the only way to surface the Sheet is to dispatch the controller's open action manually from JS.
Use case: clicking a table row dispatches a GET accepting text/vnd.turbo-stream.html; the response targets a turbo_frame_tag in the layout with turbo_stream.update("FRAME_ID", Sheet(open: true) { ... }). The Sheet appears as soon as the stream lands.
Implementation
RubyUI::Sheet#initializenow acceptsopen: falseand forwards remaining**attrstosuper.default_attrsexposes the value to Stimulus viadata-ruby-ui--sheet-open-value.sheet_controller.jsdeclaresstatic values = { open: false }and callsthis.open()onconnect()whenopenValueis true.- Defaults to
false, so existing usage is unchanged.
Tests
test_render_closed_by_default— confirms the data attribute defaults to"false".test_render_open_when_open_is_true— confirmsSheet(open: true)emitsdata-ruby-ui--sheet-open-value="true".
Existing test (test_render_with_all_items) still passes — additive change only.
Summary by cubic
Adds an open: option to RubyUI::Sheet to render a Sheet already open on the initial response. Enables Turbo Stream/server-driven renders to show the Sheet without a SheetTrigger; defaults to closed for backward compatibility.
- New Features
- Add
open:toRubyUI::Sheet, exposingdata-ruby-ui--sheet-open-valuefor Stimulus. - Controller reads
openValueand callsopen()on connect when true. - Works with Turbo Stream updates; no manual JS dispatch needed.
- Add