Render the company toggle as Gloss checkbox row, not a field
A checkbox is no Field control: Gloss styles a bare label wrapping one
as an inline row, and the field-shaped label stacked an uppercase mono
caption over a lone 18px box.
Assisted-by: GLM-5.3 via pi
diff --git a/lib/pro_tacts/admin/contact_dialog.rb b/lib/pro_tacts/admin/contact_dialog.rb
index dd10ae3..e464fb4 100644
--- a/lib/pro_tacts/admin/contact_dialog.rb
+++ b/lib/pro_tacts/admin/contact_dialog.rb
@@ -62,16 +62,19 @@ module ProTacts
header { "New contact" }
form(id: "new-contact-form", action: "/contacts", method: "post",
x_data: "{ company: false, #{NamePair.state(nil, nil)} }") do
- # The company toggle: an organization is made here, not by
- # converting a person later — checking it hides the pair
- # and asks for the one name an organization is known by
+ # The company toggle: a Gloss checkbox row, not a field —
+ # a checkbox is no Field control (Gloss's Checkbox contract
+ # styles the bare label wrapping one as an inline row), and
+ # the quiet option reads as what the name fields stand
+ # behind. Checking it hides the pair and asks for the one
+ # name an organization is known by
# (CardForm.new_org_card). x-model both ways, so the state
# the fields bind to is the checkbox's own, and the
# submitted `company` param is the browser's serialization
# of a checked box.
- label(class: "field") do
- plain "Company"
+ label do
input(type: "checkbox", name: "company", value: "1", x_model: "company")
+ plain "Company"
end
label(class: "field", x_show: "!company") do
plain "First"
diff --git a/test/pro_tacts/admin/test_contacts_pages.rb b/test/pro_tacts/admin/test_contacts_pages.rb
index 254fa4e..ee01aa8 100644
--- a/test/pro_tacts/admin/test_contacts_pages.rb
+++ b/test/pro_tacts/admin/test_contacts_pages.rb
@@ -1101,8 +1101,7 @@ class AdminContactsPagesTest < Minitest::Test
# assertion keeps a regression from rendering a silent label).
# The Company toggle swaps the pair for the one organization
# box, and every field is required only while shown.
- assert_includes body, '<label class="field">Company' \
- '<input type="checkbox" name="company" value="1" x-model="company"></label>'
+ assert_includes body, '<label><input type="checkbox" name="company" value="1" x-model="company">Company</label>'
assert_includes body, '<label class="field" x-show="!company">First<input type="text" name="first" required ' \
':required="!company && lastBlank" @input="firstBlank = !$el.value.trim()" autofocus></label>'
assert_includes body, '<label class="field" x-show="!company">Middle<input type="text" name="middle"></label>'