From fe7f71171052fcc218cd010d4777bdc6f6d8dc25 Mon Sep 17 00:00:00 2001 From: "Nate Hopkins (hopsoft)" Date: Mon, 20 May 2024 15:46:35 -0600 Subject: [PATCH] Update to use current state for checks --- app/commands/turbo_boost/elements/toggle_command.rb | 8 +++++++- .../elements/tag_builders/toggle_tags_builder.rb | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/commands/turbo_boost/elements/toggle_command.rb b/app/commands/turbo_boost/elements/toggle_command.rb index 6235c19..88ca36f 100644 --- a/app/commands/turbo_boost/elements/toggle_command.rb +++ b/app/commands/turbo_boost/elements/toggle_command.rb @@ -17,7 +17,13 @@ def show def hide validate_element! - state[element.aria.controls] = false + + if element.remember? + state[element.aria.controls] = false + else + state.now[element.aria.controls] = false + end + morph id: element.morphs, html: render(element.render_options) end 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 c5f3c42..a5233bb 100644 --- a/lib/turbo_boost/elements/tag_builders/toggle_tags_builder.rb +++ b/lib/turbo_boost/elements/tag_builders/toggle_tags_builder.rb @@ -82,7 +82,7 @@ def target_tag( end def target_expanded?(dom_id) - !!controller_pack.state[dom_id] + !!controller_pack.state.current[dom_id] end def target_collapsed?(dom_id)