From 9d122d86f142c004c32b88984e168b1198e87653 Mon Sep 17 00:00:00 2001 From: Nate Hopkins Date: Mon, 6 Feb 2023 13:53:03 -0700 Subject: [PATCH] Expanded override for trigger as well as target (#36) --- lib/turbo_boost/elements/tag_builders/toggle_tags_builder.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/turbo_boost/elements/tag_builders/toggle_tags_builder.rb b/lib/turbo_boost/elements/tag_builders/toggle_tags_builder.rb index 6135a97..c662a63 100644 --- a/lib/turbo_boost/elements/tag_builders/toggle_tags_builder.rb +++ b/lib/turbo_boost/elements/tag_builders/toggle_tags_builder.rb @@ -22,6 +22,7 @@ def trigger_tag( focus_selector: nil, # CSS selector for the element to focus when the target is expanded method: :toggle, # method to inovke (:show, :hide, :toggle) disabled: false, # disable the trigger + expanded: false, # override to force expansion remember: false, # remember ephemeral UI state between requests **kwargs, # generic support for additional element attributes like `class` etc. &block # a Ruby block that emits this trigger's content @@ -36,7 +37,7 @@ def trigger_tag( # aria kwargs[:aria] ||= {} kwargs[:aria][:controls] = controls # toggle target - kwargs[:aria][:expanded] = target_expanded?(controls) + kwargs[:aria][:expanded] = expanded || target_expanded?(controls) kwargs[:aria][:atomic] ||= true kwargs[:aria][:relevant] ||= "all" @@ -57,8 +58,8 @@ def target_tag( id, # REQUIRED, the `dom_id` for the element collapse_on: [], # list of events that will collapse this target collapse_selector: nil, # CSS selector for other matching targets to collapse when this target is expanded - expanded: false, # override to force expansion focus_selector: nil, # CSS selector for the element to focus when this target is expanded + expanded: false, # override to force expansion **kwargs, # generic support for additional element attributes like `class` etc. &block # a Ruby block that emits this target's content )