Skip to content

Commit

Permalink
Always set :absolute position on Primer::Alpha::Tooltip (#1281)
Browse files Browse the repository at this point in the history
* Always set `:absolute` position on Tooltip

* docs: build docs

* Adding a test

* Create honest-vans-fold.md

Co-authored-by: Actions Auto Build <actions@github.com>
  • Loading branch information
jonrohan and actions-user committed Aug 5, 2022
1 parent 1e9ce95 commit 843061d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/honest-vans-fold.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@primer/view-components": patch
---

Always set `:absolute` position on Primer::Alpha::Tooltip
1 change: 1 addition & 0 deletions app/components/primer/alpha/tooltip.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions static/classes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@
- ".p-3"
- ".p-4"
- ".p-5"
- ".position-absolute"
- ".position-relative"
- ".pr-2"
- ".pt-5"
Expand Down
5 changes: 5 additions & 0 deletions test/components/alpha/tooltip_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 843061d

Please sign in to comment.