Skip to content

Commit

Permalink
Showing the tooltip on focus-within (#2750)
Browse files Browse the repository at this point in the history
* Showing the tooltip on focus-within

* Adding changeset

* Updating snapshots

Co-authored-by: Ian Sanders <iansan5653@github.com>
  • Loading branch information
jdrush89 and iansan5653 committed Jan 10, 2023
1 parent b55d823 commit dcb51c6
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 12 deletions.
5 changes: 5 additions & 0 deletions .changeset/shaggy-stingrays-fly.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/react': patch
---

Show tooltips on focus-within
9 changes: 6 additions & 3 deletions src/Tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ const TooltipBase = styled.span<SxProp>`
&:hover,
&:active,
&:focus {
&:focus,
&:focus-within {
&::before,
&::after {
display: inline-block;
Expand All @@ -71,7 +72,8 @@ const TooltipBase = styled.span<SxProp>`
&.tooltipped-no-delay:hover,
&.tooltipped-no-delay:active,
&.tooltipped-no-delay:focus {
&.tooltipped-no-delay:focus,
&.tooltipped-no-delay:focus-within {
&::before,
&::after {
animation-delay: 0s;
Expand All @@ -80,7 +82,8 @@ const TooltipBase = styled.span<SxProp>`
&.tooltipped-multiline:hover,
&.tooltipped-multiline:active,
&.tooltipped-multiline:focus {
&.tooltipped-multiline:focus,
&.tooltipped-multiline:focus-within {
&::after {
display: table-cell;
}
Expand Down
22 changes: 16 additions & 6 deletions src/__tests__/__snapshots__/TextInput.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1469,9 +1469,11 @@ exports[`TextInput renders trailingAction icon button 1`] = `
.c3:hover::before,
.c3:active::before,
.c3:focus::before,
.c3:focus-within::before,
.c3:hover::after,
.c3:active::after,
.c3:focus::after {
.c3:focus::after,
.c3:focus-within::after {
display: inline-block;
-webkit-text-decoration: none;
text-decoration: none;
Expand All @@ -1490,16 +1492,19 @@ exports[`TextInput renders trailingAction icon button 1`] = `
.c3.tooltipped-no-delay:hover::before,
.c3.tooltipped-no-delay:active::before,
.c3.tooltipped-no-delay:focus::before,
.c3.tooltipped-no-delay:focus-within::before,
.c3.tooltipped-no-delay:hover::after,
.c3.tooltipped-no-delay:active::after,
.c3.tooltipped-no-delay:focus::after {
.c3.tooltipped-no-delay:focus::after,
.c3.tooltipped-no-delay:focus-within::after {
-webkit-animation-delay: 0s;
animation-delay: 0s;
}
.c3.tooltipped-multiline:hover::after,
.c3.tooltipped-multiline:active::after,
.c3.tooltipped-multiline:focus::after {
.c3.tooltipped-multiline:focus::after,
.c3.tooltipped-multiline:focus-within::after {
display: table-cell;
}
Expand Down Expand Up @@ -2212,9 +2217,11 @@ exports[`TextInput renders trailingAction text button with a tooltip 1`] = `
.c3:hover::before,
.c3:active::before,
.c3:focus::before,
.c3:focus-within::before,
.c3:hover::after,
.c3:active::after,
.c3:focus::after {
.c3:focus::after,
.c3:focus-within::after {
display: inline-block;
-webkit-text-decoration: none;
text-decoration: none;
Expand All @@ -2233,16 +2240,19 @@ exports[`TextInput renders trailingAction text button with a tooltip 1`] = `
.c3.tooltipped-no-delay:hover::before,
.c3.tooltipped-no-delay:active::before,
.c3.tooltipped-no-delay:focus::before,
.c3.tooltipped-no-delay:focus-within::before,
.c3.tooltipped-no-delay:hover::after,
.c3.tooltipped-no-delay:active::after,
.c3.tooltipped-no-delay:focus::after {
.c3.tooltipped-no-delay:focus::after,
.c3.tooltipped-no-delay:focus-within::after {
-webkit-animation-delay: 0s;
animation-delay: 0s;
}
.c3.tooltipped-multiline:hover::after,
.c3.tooltipped-multiline:active::after,
.c3.tooltipped-multiline:focus::after {
.c3.tooltipped-multiline:focus::after,
.c3.tooltipped-multiline:focus-within::after {
display: table-cell;
}
Expand Down
11 changes: 8 additions & 3 deletions src/__tests__/__snapshots__/Tooltip.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,11 @@ exports[`Tooltip renders consistently 1`] = `
.c0:hover::before,
.c0:active::before,
.c0:focus::before,
.c0:focus-within::before,
.c0:hover::after,
.c0:active::after,
.c0:focus::after {
.c0:focus::after,
.c0:focus-within::after {
display: inline-block;
-webkit-text-decoration: none;
text-decoration: none;
Expand All @@ -68,16 +70,19 @@ exports[`Tooltip renders consistently 1`] = `
.c0.tooltipped-no-delay:hover::before,
.c0.tooltipped-no-delay:active::before,
.c0.tooltipped-no-delay:focus::before,
.c0.tooltipped-no-delay:focus-within::before,
.c0.tooltipped-no-delay:hover::after,
.c0.tooltipped-no-delay:active::after,
.c0.tooltipped-no-delay:focus::after {
.c0.tooltipped-no-delay:focus::after,
.c0.tooltipped-no-delay:focus-within::after {
-webkit-animation-delay: 0s;
animation-delay: 0s;
}
.c0.tooltipped-multiline:hover::after,
.c0.tooltipped-multiline:active::after,
.c0.tooltipped-multiline:focus::after {
.c0.tooltipped-multiline:focus::after,
.c0.tooltipped-multiline:focus-within::after {
display: table-cell;
}
Expand Down

0 comments on commit dcb51c6

Please sign in to comment.