Skip to content

Commit 97d988b

Browse files
authored
fix: Avoid cropping popover trigger focus ring when not wrapping text (#4116)
1 parent 8568662 commit 97d988b

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@
175175
{
176176
"path": "lib/components/internal/widget-exports.js",
177177
"brotli": false,
178-
"limit": "1040 kB",
178+
"limit": "1100 kB",
179179
"ignore": "react-dom"
180180
}
181181
],

pages/popover/text-wrap.page.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import React from 'react';
55
import Popover, { PopoverProps } from '~components/popover';
66
import PopoverBody, { PopoverBodyProps } from '~components/popover/body';
77

8+
import FocusTarget from '../common/focus-target';
89
import createPermutations from '../utils/permutations';
910
import PermutationsView from '../utils/permutations-view';
1011
import ScreenshotArea from '../utils/screenshot-area';
@@ -59,6 +60,7 @@ export default function () {
5960
return (
6061
<article>
6162
<h1>Popover text wrapping</h1>
63+
<FocusTarget />
6264
<ScreenshotArea>
6365
<PermutationsView
6466
permutations={triggerPermutations}

src/popover/styles.scss

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,15 @@ $trigger-underline-offset: 0.25em;
2020
&.no-wrap {
2121
white-space: nowrap;
2222
}
23+
24+
// When the trigger text is set to be ellipsized, render the focus ring on the root element instead of the trigger,
25+
// to prevent it from being cropped by its `overflow: hidden` rule.
26+
// We do this in only this case because when the trigger has multiple lines of texts its height can differ from the root element.
27+
&:has(.trigger-type-text-inline.overflow-ellipsis:focus, .trigger-type-text.overflow-ellipsis:focus) {
28+
@include focus-visible.when-visible-unfocused {
29+
@include styles.focus-highlight(1px);
30+
}
31+
}
2332
}
2433

2534
.root-filtering-token {
@@ -77,8 +86,10 @@ $trigger-underline-offset: 0.25em;
7786
outline: none;
7887
}
7988

80-
@include focus-visible.when-visible {
81-
@include styles.focus-highlight(1px);
89+
&:not(.overflow-ellipsis) {
90+
@include focus-visible.when-visible {
91+
@include styles.focus-highlight(1px);
92+
}
8293
}
8394
}
8495

0 commit comments

Comments
 (0)