Skip to content

Commit

Permalink
Set platform classes on fieldset
Browse files Browse the repository at this point in the history
  • Loading branch information
josefarias committed Nov 18, 2024
1 parent 8708c98 commit 6933d44
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
11 changes: 1 addition & 10 deletions app/presenters/hotwire_combobox/component/markup/dialog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ def dialog_wrapper_attrs

def dialog_attrs
customize :dialog, base: {
class: "hw-combobox__dialog #{platform_classes}", role: :dialog, data: {
class: "hw-combobox__dialog", role: :dialog, data: {
action: "keydown->hw-combobox#navigate", hw_combobox_target: "dialog" } }
end

Expand Down Expand Up @@ -34,15 +34,6 @@ def dialog_focus_trap_attrs
end

private
def platform_classes
platform = HotwireCombobox::Platform.new request&.user_agent

view.token_list \
"hw-combobox--ios": platform.ios?,
"hw-combobox--android": platform.android?,
"hw-combobox--mobile-webkit": platform.mobile_webkit?
end

def dialog_input_id
"#{canonical_id}-hw-dialog-combobox"
end
Expand Down
11 changes: 10 additions & 1 deletion app/presenters/hotwire_combobox/component/markup/fieldset.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
module HotwireCombobox::Component::Markup::Fieldset
def fieldset_attrs
customize :fieldset, base: {
class: [ "hw-combobox", { "hw-combobox--multiple": multiselect? } ], data: fieldset_data }
class: [ "hw-combobox", platform_classes, { "hw-combobox--multiple": multiselect? } ], data: fieldset_data }
end

private
def platform_classes
platform = HotwireCombobox::Platform.new request&.user_agent

view.token_list \
"hw-combobox--ios": platform.ios?,
"hw-combobox--android": platform.android?,
"hw-combobox--mobile-webkit": platform.mobile_webkit?
end

def fieldset_data
data.merge \
async_id: canonical_id,
Expand Down

0 comments on commit 6933d44

Please sign in to comment.