Skip to content

Commit 320ea86

Browse files
fix(settings): make tooltip text start-aligned instead of centered
Because: * Error tooltip text is centered and should be RTL or LTR This commit: * makes tooltip text start-aligned instead of centered and adds a story to showcase the multiline scenario. * fixes the bug where a tooltip is limited to have half the width of its parent when anchor position is set to middle. Closes #FXA-11351
1 parent 44a2de2 commit 320ea86

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

packages/fxa-settings/src/components/Tooltip/index.stories.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,17 @@ export const Default = () => (
2828
<Tooltip message="My tooltip message here" />
2929
</>
3030
);
31+
32+
export const MultilineMessage = () => (
33+
<>
34+
<p>Default tooltip pointing to this text</p>
35+
<Tooltip
36+
message="This is a very very very very very very long message"
37+
anchorPosition="start"
38+
/>
39+
</>
40+
);
41+
3142
export const Bottom = () => (
3243
<>
3344
<p>Default tooltip pointing to this text</p>

packages/fxa-settings/src/components/Tooltip/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,14 @@ export const Tooltip = ({
4949
data-testid={formatDataTestId('tooltip')}
5050
aria-live="polite"
5151
className={classNames(
52-
`z-50 absolute py-2 px-6 text-center text-white
52+
`z-50 absolute py-2 px-6 text-white
5353
rounded text-xs font-header font-bold
5454
shadow-tooltip-grey-drop border-transparent border border-solid
5555
`,
5656
type === 'error' ? 'bg-red-600' : 'bg-grey-500',
5757
className,
5858
{
59-
'ltr:left-1/2 ltr:-translate-x-1/2 rtl:right-1/2 rtl:translate-x-1/2':
59+
'ltr:left-1/2 ltr:-translate-x-1/2 rtl:right-1/2 rtl:translate-x-1/2 w-max max-w-full':
6060
anchorPosition === 'middle',
6161
'start-0': anchorPosition === 'start',
6262
'end-0 me-1': anchorPosition === 'end',

0 commit comments

Comments
 (0)