mirror of
https://github.com/we-promise/sure.git
synced 2026-07-12 04:45:19 +00:00
Commit 5d0eb7f4 replaced the color picker's DS::Disclosure with a raw
<details> because DS::Disclosure wraps its body in an mt-2 div, and that
normal-flow margin shoved the form down ~8px whenever the absolutely-
positioned picker popover opened. DS Drift Patrol flagged the raw
<details> in #2272 and #2316.
Add a body_class: option to DS::Disclosure (default mt-2) so callers can
drop the body margin, and migrate the color picker back onto the
component with body_class: nil. The summary's accessible name moves from
aria-label to an sr-only span in the summary content (verified: the
summary still reads as "Choose color and icon").
29 lines
1011 B
Ruby
29 lines
1011 B
Ruby
require "test_helper"
|
|
|
|
class DS::DisclosureTest < ViewComponent::TestCase
|
|
test "body wrapper defaults to an mt-2 margin" do
|
|
render_inline(DS::Disclosure.new(title: "More", open: true)) { "body text" }
|
|
|
|
assert_selector "details > div.mt-2", text: "body text"
|
|
end
|
|
|
|
test "body_class: nil drops the body margin wrapper" do
|
|
render_inline(DS::Disclosure.new(title: "More", open: true, body_class: nil)) { "body text" }
|
|
|
|
assert_no_selector "details > div.mt-2"
|
|
assert_selector "details > div", text: "body text"
|
|
end
|
|
|
|
test "forwards data attributes and a summary_class override" do
|
|
render_inline(DS::Disclosure.new(
|
|
summary_class: "custom-summary",
|
|
data: { controller: "color-icon-picker", action: "mousedown->color-icon-picker#handleOutsideClick" }
|
|
)) do |disclosure|
|
|
disclosure.with_summary_content { "trigger" }
|
|
end
|
|
|
|
assert_selector "details[data-controller='color-icon-picker']"
|
|
assert_selector "summary.custom-summary", text: "trigger"
|
|
end
|
|
end
|