Skip to content

Commit

Permalink
chore(suite): remove needless and confusing 'disabled' prop from tooltip
Browse files Browse the repository at this point in the history
  • Loading branch information
vojtatranta committed Feb 6, 2025
1 parent 92db339 commit 2ad4cc0
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 10 deletions.
22 changes: 22 additions & 0 deletions packages/components/src/components/Tooltip/Tooltip.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,26 @@ describe('Tooltip', () => {
const parent = triggerBefore.parentElement;
expect(parent).toHaveAttribute('data-state', 'closed');
});

it('should apply the cursor prop to the content wrapper', () => {
const tooltipContent = 'Tooltip Content';
render(
<Tooltip content={tooltipContent} cursor="pointer">
<button>Hover me</button>
</Tooltip>,
);

expect(screen.getByText('Hover me').parentElement).toHaveStyle({ cursor: 'pointer' });
});

it('should should apply the default=help cursor when the passed cursor is undefined', () => {
const tooltipContent = 'Tooltip Content';
render(
<Tooltip content={tooltipContent} cursor={undefined}>
<button>Hover me</button>
</Tooltip>,
);

expect(screen.getByText('Hover me').parentElement).toHaveStyle({ cursor: 'help' });
});
});
9 changes: 1 addition & 8 deletions packages/components/src/components/Tooltip/Tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ type TooltipUiProps = {
children: ReactNode;
className?: string;
dashed?: boolean;
disabled?: boolean;
offset?: number;
shift?: ShiftOptions;
cursor?: Cursor;
Expand All @@ -70,7 +69,6 @@ export type TooltipProps = (ManagedModeProps | UnmanagedModeProps) &
export const Tooltip = ({
isActive = true, // NOTE: determines, if the tooltip is actually working - is displayed, reacts to the events
placement = 'top',
disabled = false, // NOTE: determines the appearance of the cursor over the tooltip trigger
children,
isLarge = false,
dashed = false,
Expand Down Expand Up @@ -111,12 +109,7 @@ export const Tooltip = ({
delay={delayConfiguration}
>
<TooltipTrigger>
<Content
$dashed={dashed}
$isInline={isInline}
$cursor={disabled ? 'not-allowed' : cursor}
as={elType}
>
<Content $dashed={dashed} $isInline={isInline} $cursor={cursor} as={elType}>
{children}
{hasIcon && <Icon name="question" size="medium" />}
</Content>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ export const DeviceSelector = () => {
isActive={discoveryInProgress}
isFullWidth
placement="bottom"
cursor="not-allowed"
content={<Translation id="TR_UNAVAILABLE_WHILE_LOADING" />}
>
<InnerContainer
Expand Down
2 changes: 1 addition & 1 deletion packages/suite/src/views/dashboard/PromoBanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ const StoreBadge = ({
return (
<Tooltip
isOpen={isTooltipOpen}
disabled={isMobileLayout}
cursor={isMobileLayout ? 'not-allowed' : undefined}
content={
<Column alignItems="center">
<StoreTitle
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,10 @@ export const FirmwareVersion = ({ isDeviceLocked }: FirmwareVersionProps) => {
id="TR_YOUR_FIRMWARE_VERSION"
values={{
version: (
<VersionTooltip content={revision} disabled={!revision}>
<VersionTooltip
content={revision}
cursor={!revision ? 'not-allowed' : undefined}
>
{revision ? (
<TrezorLink href={changelogUrl} variant="nostyle">
<GithubButton />
Expand Down

0 comments on commit 2ad4cc0

Please sign in to comment.