diff --git a/.changeset/honest-vans-fold.md b/.changeset/honest-vans-fold.md new file mode 100644 index 0000000000..d6e81fa63e --- /dev/null +++ b/.changeset/honest-vans-fold.md @@ -0,0 +1,5 @@ +--- +"@primer/view-components": patch +--- + +Always set `:absolute` position on Primer::Alpha::Tooltip diff --git a/app/components/primer/alpha/tooltip.rb b/app/components/primer/alpha/tooltip.rb index 1ebd295209..7211320282 100644 --- a/app/components/primer/alpha/tooltip.rb +++ b/app/components/primer/alpha/tooltip.rb @@ -91,6 +91,7 @@ def initialize(type:, for_id:, text:, direction: DIRECTION_DEFAULT, **system_arg @system_arguments[:tag] = :"tool-tip" @system_arguments[:style] = join_style_arguments(@system_arguments[:style], "visibility: hidden") @system_arguments[:for] = for_id + @system_arguments[:position] = :absolute @system_arguments[:"data-direction"] = fetch_or_fallback(DIRECTION_OPTIONS, direction, DIRECTION_DEFAULT).to_s @system_arguments[:"data-type"] = fetch_or_fallback(TYPE_OPTIONS, type, TYPE_FALLBACK).to_s end diff --git a/static/classes.yml b/static/classes.yml index ed2aa620b3..0d0596eb96 100644 --- a/static/classes.yml +++ b/static/classes.yml @@ -212,6 +212,7 @@ - ".p-3" - ".p-4" - ".p-5" +- ".position-absolute" - ".position-relative" - ".pr-2" - ".pt-5" diff --git a/test/components/alpha/tooltip_test.rb b/test/components/alpha/tooltip_test.rb index 6f9d5c630d..3bfc2c1622 100644 --- a/test/components/alpha/tooltip_test.rb +++ b/test/components/alpha/tooltip_test.rb @@ -29,4 +29,9 @@ def test_raises_if_text_is_not_string render_inline(Primer::Alpha::Tooltip.new(type: :description, for_id: "someButton", text: not_text, visible: false)) end end + + def test_tooltip_is_position_absolute + render_inline(Primer::Alpha::Tooltip.new(type: :description, for_id: "someButton", text: "Tooltip")) + assert_selector("tool-tip.position-absolute", visible: false) + end end