Skip to content

Commit

Permalink
Ensure full_width: option is respected by the auto_complete input (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
camertron authored Nov 25, 2024
1 parent 14dd0d3 commit 79ca4f9
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/seven-experts-return.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/view-components': patch
---

Ensure `full_width:` option is respected by the auto_complete input
3 changes: 2 additions & 1 deletion app/lib/primer/forms/auto_complete.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ def auto_complete_arguments
input_name: all_args[:name],
input_id: all_args[:id],
label_text: @input.label,
list_id: "#{all_args[:id]}-list"
list_id: "#{all_args[:id]}-list",
full_width: @input.full_width?
)
end

Expand Down
24 changes: 24 additions & 0 deletions test/lib/primer/forms/auto_complete_input_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,28 @@ def test_only_primer_error_markup
# no rails error markup
refute_selector ".field_with_errors", visible: :all
end

def test_full_width_by_default
render_in_view_context do
primer_form_with(url: "/foo") do |f|
render_inline_form(f) do |auto_complete_form|
auto_complete_form.auto_complete(name: :foo, label: "Foo", src: "/foo")
end
end
end

assert_selector ".FormControl--fullWidth"
end

def test_full_width_can_be_disabled
render_in_view_context do
primer_form_with(url: "/foo") do |f|
render_inline_form(f) do |auto_complete_form|
auto_complete_form.auto_complete(name: :foo, label: "Foo", src: "/foo", full_width: false)
end
end
end

refute_selector ".FormControl--fullWidth"
end
end

0 comments on commit 79ca4f9

Please sign in to comment.