Skip to content

Commit 6f865ed

Browse files
fix: definition tooltip breaks with large text (#17964)
* fix: definition tooltip breaks with large text * fix: definition tooltip breaks with large text * docs: added name in contributor list * fix: added padding to arrow in case caret is not in center * fix: test case * fix: position issues * fix: position issues * fix: merge conflicts * fix: format * fix: without autoAlign * fix: resolve conflict * fix: removing autoAlign changes * fix: removed largeText Story * fix: lint issue --------- Co-authored-by: Taylor Jones <taylor.jones826@gmail.com>
1 parent ab51f11 commit 6f865ed

File tree

6 files changed

+79
-26
lines changed

6 files changed

+79
-26
lines changed

.all-contributorsrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,13 @@
165165
"a11y"
166166
]
167167
},
168+
{
169+
"login": "preetibansalui",
170+
"name": "Preeti Bansal",
171+
"avatar_url": "https://avatars.githubusercontent.com/u/146315451?v=4",
172+
"profile": "https://github.com/preetibansalui",
173+
"contributions": ["code", "a11y"]
174+
},
168175
{
169176
"login": "erifsx",
170177
"name": "Eric Marcoux",

README.md

Lines changed: 26 additions & 25 deletions
Large diffs are not rendered by default.

packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2877,6 +2877,9 @@ Map {
28772877
],
28782878
"type": "oneOf",
28792879
},
2880+
"autoAlign": Object {
2881+
"type": "bool",
2882+
},
28802883
"children": Object {
28812884
"isRequired": true,
28822885
"type": "node",

packages/react/src/components/Tooltip/DefinitionTooltip.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ export interface DefinitionTooltipProps
2424
*/
2525
align?: PopoverAlignment;
2626

27+
/**
28+
* Will auto-align Definition Tooltip. This prop is currently experimental and is subject to future changes.
29+
*/
30+
autoAlign?: boolean;
31+
2732
/**
2833
* The `children` prop will be used as the value that is being defined
2934
*/
@@ -70,7 +75,8 @@ export interface DefinitionTooltipProps
7075
}
7176

7277
const DefinitionTooltip: React.FC<DefinitionTooltipProps> = ({
73-
align = 'bottom-start',
78+
align = 'bottom',
79+
autoAlign,
7480
className,
7581
children,
7682
definition,
@@ -96,6 +102,7 @@ const DefinitionTooltip: React.FC<DefinitionTooltipProps> = ({
96102
<Popover
97103
align={align}
98104
className={className}
105+
autoAlign={autoAlign}
99106
dropShadow={false}
100107
highContrast
101108
onMouseLeave={() => {
@@ -166,6 +173,11 @@ DefinitionTooltip.propTypes = {
166173
'right-start',
167174
]),
168175

176+
/**
177+
* Will auto-align the popover. This prop is currently experimental and is subject to future changes.
178+
*/
179+
autoAlign: PropTypes.bool,
180+
169181
/**
170182
* The `children` prop will be used as the value that is being defined
171183
*/

packages/styles/scss/components/popover/_popover.scss

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,35 @@ $popover-caret-height: custom-property.get-var(
266266
transform: translate($popover-offset, calc(100% + $popover-offset));
267267
}
268268

269+
.#{$prefix}--popover--bottom-end:not(.#{$prefix}--popover--auto-align)
270+
> .#{$prefix}--popover
271+
> .#{$prefix}--popover-caret,
272+
.#{$prefix}--popover--top-end:not(.#{$prefix}--popover--auto-align)
273+
> .#{$prefix}--popover
274+
> .#{$prefix}--popover-caret {
275+
inset-block-end: 0;
276+
inset-inline-end: 0;
277+
inset-inline-start: auto;
278+
}
279+
280+
.#{$prefix}--popover--bottom-start:not(.#{$prefix}--popover--auto-align)
281+
> .#{$prefix}--popover
282+
> .#{$prefix}--popover-caret {
283+
inset-block-end: 0;
284+
inset-inline-end: auto;
285+
inset-inline-start: 0;
286+
transform: translate(50%, calc($popover-offset));
287+
}
288+
289+
.#{$prefix}--popover--top-start:not(.#{$prefix}--popover--auto-align)
290+
> .#{$prefix}--popover
291+
> .#{$prefix}--popover-caret {
292+
inset-block-end: 0;
293+
inset-inline-end: auto;
294+
inset-inline-start: 0;
295+
transform: translate(50%, calc(-1 * $popover-offset));
296+
}
297+
269298
[dir='rtl']
270299
.#{$prefix}--popover--bottom-right:not(.#{$prefix}--popover--auto-align)
271300
> .#{$prefix}--popover

packages/styles/scss/components/tooltip/_tooltip.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ $tooltip-padding-inline: custom-property.get-var(
6464
padding: convert.to-rem(8px) convert.to-rem(16px);
6565
max-inline-size: convert.to-rem(176px);
6666
text-wrap: auto;
67+
word-break: break-word;
6768
}
6869
}
6970

0 commit comments

Comments
 (0)