Skip to content

Commit dcb51c6

Browse files
jdrush89iansan5653
andauthored
Showing the tooltip on focus-within (#2750)
* Showing the tooltip on focus-within * Adding changeset * Updating snapshots Co-authored-by: Ian Sanders <[email protected]>
1 parent b55d823 commit dcb51c6

File tree

4 files changed

+35
-12
lines changed

4 files changed

+35
-12
lines changed

.changeset/shaggy-stingrays-fly.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@primer/react': patch
3+
---
4+
5+
Show tooltips on focus-within

src/Tooltip.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ const TooltipBase = styled.span<SxProp>`
5656
5757
&:hover,
5858
&:active,
59-
&:focus {
59+
&:focus,
60+
&:focus-within {
6061
&::before,
6162
&::after {
6263
display: inline-block;
@@ -71,7 +72,8 @@ const TooltipBase = styled.span<SxProp>`
7172
7273
&.tooltipped-no-delay:hover,
7374
&.tooltipped-no-delay:active,
74-
&.tooltipped-no-delay:focus {
75+
&.tooltipped-no-delay:focus,
76+
&.tooltipped-no-delay:focus-within {
7577
&::before,
7678
&::after {
7779
animation-delay: 0s;
@@ -80,7 +82,8 @@ const TooltipBase = styled.span<SxProp>`
8082
8183
&.tooltipped-multiline:hover,
8284
&.tooltipped-multiline:active,
83-
&.tooltipped-multiline:focus {
85+
&.tooltipped-multiline:focus,
86+
&.tooltipped-multiline:focus-within {
8487
&::after {
8588
display: table-cell;
8689
}

src/__tests__/__snapshots__/TextInput.test.tsx.snap

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1469,9 +1469,11 @@ exports[`TextInput renders trailingAction icon button 1`] = `
14691469
.c3:hover::before,
14701470
.c3:active::before,
14711471
.c3:focus::before,
1472+
.c3:focus-within::before,
14721473
.c3:hover::after,
14731474
.c3:active::after,
1474-
.c3:focus::after {
1475+
.c3:focus::after,
1476+
.c3:focus-within::after {
14751477
display: inline-block;
14761478
-webkit-text-decoration: none;
14771479
text-decoration: none;
@@ -1490,16 +1492,19 @@ exports[`TextInput renders trailingAction icon button 1`] = `
14901492
.c3.tooltipped-no-delay:hover::before,
14911493
.c3.tooltipped-no-delay:active::before,
14921494
.c3.tooltipped-no-delay:focus::before,
1495+
.c3.tooltipped-no-delay:focus-within::before,
14931496
.c3.tooltipped-no-delay:hover::after,
14941497
.c3.tooltipped-no-delay:active::after,
1495-
.c3.tooltipped-no-delay:focus::after {
1498+
.c3.tooltipped-no-delay:focus::after,
1499+
.c3.tooltipped-no-delay:focus-within::after {
14961500
-webkit-animation-delay: 0s;
14971501
animation-delay: 0s;
14981502
}
14991503
15001504
.c3.tooltipped-multiline:hover::after,
15011505
.c3.tooltipped-multiline:active::after,
1502-
.c3.tooltipped-multiline:focus::after {
1506+
.c3.tooltipped-multiline:focus::after,
1507+
.c3.tooltipped-multiline:focus-within::after {
15031508
display: table-cell;
15041509
}
15051510
@@ -2212,9 +2217,11 @@ exports[`TextInput renders trailingAction text button with a tooltip 1`] = `
22122217
.c3:hover::before,
22132218
.c3:active::before,
22142219
.c3:focus::before,
2220+
.c3:focus-within::before,
22152221
.c3:hover::after,
22162222
.c3:active::after,
2217-
.c3:focus::after {
2223+
.c3:focus::after,
2224+
.c3:focus-within::after {
22182225
display: inline-block;
22192226
-webkit-text-decoration: none;
22202227
text-decoration: none;
@@ -2233,16 +2240,19 @@ exports[`TextInput renders trailingAction text button with a tooltip 1`] = `
22332240
.c3.tooltipped-no-delay:hover::before,
22342241
.c3.tooltipped-no-delay:active::before,
22352242
.c3.tooltipped-no-delay:focus::before,
2243+
.c3.tooltipped-no-delay:focus-within::before,
22362244
.c3.tooltipped-no-delay:hover::after,
22372245
.c3.tooltipped-no-delay:active::after,
2238-
.c3.tooltipped-no-delay:focus::after {
2246+
.c3.tooltipped-no-delay:focus::after,
2247+
.c3.tooltipped-no-delay:focus-within::after {
22392248
-webkit-animation-delay: 0s;
22402249
animation-delay: 0s;
22412250
}
22422251
22432252
.c3.tooltipped-multiline:hover::after,
22442253
.c3.tooltipped-multiline:active::after,
2245-
.c3.tooltipped-multiline:focus::after {
2254+
.c3.tooltipped-multiline:focus::after,
2255+
.c3.tooltipped-multiline:focus-within::after {
22462256
display: table-cell;
22472257
}
22482258

src/__tests__/__snapshots__/Tooltip.test.tsx.snap

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,11 @@ exports[`Tooltip renders consistently 1`] = `
4747
.c0:hover::before,
4848
.c0:active::before,
4949
.c0:focus::before,
50+
.c0:focus-within::before,
5051
.c0:hover::after,
5152
.c0:active::after,
52-
.c0:focus::after {
53+
.c0:focus::after,
54+
.c0:focus-within::after {
5355
display: inline-block;
5456
-webkit-text-decoration: none;
5557
text-decoration: none;
@@ -68,16 +70,19 @@ exports[`Tooltip renders consistently 1`] = `
6870
.c0.tooltipped-no-delay:hover::before,
6971
.c0.tooltipped-no-delay:active::before,
7072
.c0.tooltipped-no-delay:focus::before,
73+
.c0.tooltipped-no-delay:focus-within::before,
7174
.c0.tooltipped-no-delay:hover::after,
7275
.c0.tooltipped-no-delay:active::after,
73-
.c0.tooltipped-no-delay:focus::after {
76+
.c0.tooltipped-no-delay:focus::after,
77+
.c0.tooltipped-no-delay:focus-within::after {
7478
-webkit-animation-delay: 0s;
7579
animation-delay: 0s;
7680
}
7781
7882
.c0.tooltipped-multiline:hover::after,
7983
.c0.tooltipped-multiline:active::after,
80-
.c0.tooltipped-multiline:focus::after {
84+
.c0.tooltipped-multiline:focus::after,
85+
.c0.tooltipped-multiline:focus-within::after {
8186
display: table-cell;
8287
}
8388

0 commit comments

Comments
 (0)