Skip to content

Commit

Permalink
add possibility to give title to icon helper, help with accessibility…
Browse files Browse the repository at this point in the history
… by giving an accessible label to icon
  • Loading branch information
JeanMarcMilletScality committed Nov 27, 2024
1 parent ebda998 commit 8ee0a32
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
14 changes: 14 additions & 0 deletions src/lib/components/iconhelper/IconHelper.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,18 @@ describe('Icon', () => {
expect(screen.getByText(tooltipMessage)).toBeVisible();
});
});
it('should be able to change accessible label with title', async () => {
const { Wrapper } = getWrapper();
render(
<Wrapper>
<IconHelp
tooltipMessage={'This is a tooltip'}
title="Info Helper testing"
/>
</Wrapper>,
);
await waitFor(() => {
expect(screen.getByLabelText('Info Helper testing')).toBeInTheDocument();
});
});
});
4 changes: 3 additions & 1 deletion src/lib/components/iconhelper/IconHelper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,20 @@ type IconHelpProps = {
tooltipMessage: ReactNode;
placement?: Position;
overlayStyle?: CSSProperties;
title?: string;
};

export const IconHelp = ({
tooltipMessage,
overlayStyle,
placement = 'right',
title,
}: IconHelpProps) => (
<Tooltip
overlay={tooltipMessage}
placement={placement}
overlayStyle={overlayStyle}
>
<Icon name="Info" color="buttonSecondary" />
<Icon name="Info" color="buttonSecondary" title={title} />
</Tooltip>
);

0 comments on commit 8ee0a32

Please sign in to comment.