Skip to content

Commit d612390

Browse files
committed
Merge branch 'ajr-new-tabs-GM-561' of github.com:Codecademy/gamut into ajr-new-tabs-GM-561
2 parents b65dcb8 + 2c9364b commit d612390

File tree

36 files changed

+235
-840
lines changed

36 files changed

+235
-840
lines changed

packages/gamut-kit/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
### [0.6.505](https://github.com/Codecademy/gamut/compare/@codecademy/[email protected]...@codecademy/[email protected]) (2025-05-21)
7+
8+
**Note:** Version bump only for package @codecademy/gamut-kit
9+
10+
### [0.6.504](https://github.com/Codecademy/gamut/compare/@codecademy/[email protected]...@codecademy/[email protected]) (2025-05-16)
11+
12+
**Note:** Version bump only for package @codecademy/gamut-kit
13+
614
### [0.6.503](https://github.com/Codecademy/gamut/compare/@codecademy/[email protected]...@codecademy/[email protected]) (2025-05-01)
715

816
**Note:** Version bump only for package @codecademy/gamut-kit

packages/gamut-kit/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"name": "@codecademy/gamut-kit",
33
"description": "Styleguide & Component library for Codecademy",
4-
"version": "0.6.503",
4+
"version": "0.6.505",
55
"author": "Codecademy Engineering <[email protected]>",
66
"dependencies": {
7-
"@codecademy/gamut": "62.0.6",
7+
"@codecademy/gamut": "63.0.0",
88
"@codecademy/gamut-icons": "9.42.2",
99
"@codecademy/gamut-illustrations": "0.54.3",
1010
"@codecademy/gamut-patterns": "0.10.9",

packages/gamut/CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,20 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
## [63.0.0](https://github.com/Codecademy/gamut/compare/@codecademy/[email protected]...@codecademy/[email protected]) (2025-05-21)
7+
8+
### ⚠ BREAKING CHANGES
9+
10+
- **ToolTip:** remove aria-describedby
11+
12+
### Bug Fixes
13+
14+
- **ToolTip:** remove aria-describedby ([1c676f5](https://github.com/Codecademy/gamut/commit/1c676f5b51896cd3703b802c77bff2e6c2d6347f))
15+
16+
### [62.0.7](https://github.com/Codecademy/gamut/compare/@codecademy/[email protected]...@codecademy/[email protected]) (2025-05-16)
17+
18+
**Note:** Version bump only for package @codecademy/gamut
19+
620
### [62.0.6](https://github.com/Codecademy/gamut/compare/@codecademy/[email protected]...@codecademy/[email protected]) (2025-05-01)
721

822
### Bug Fixes

packages/gamut/__tests__/__snapshots__/gamut.test.ts.snap

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ exports[`Gamut Exported Keys 1`] = `
3232
"DataList",
3333
"DataTable",
3434
"DelayedRenderWrapper",
35-
"DeprecatedToolTip",
3635
"Dialog",
3736
"Disclosure",
3837
"Drawer",

packages/gamut/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@codecademy/gamut",
33
"description": "Styleguide & Component library for Codecademy",
4-
"version": "62.0.6",
4+
"version": "63.0.0",
55
"author": "Codecademy Engineering <[email protected]>",
66
"dependencies": {
77
"@codecademy/gamut-icons": "9.42.2",

packages/gamut/src/Alert/Alert.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,6 @@ export const Alert: React.FC<AlertProps> = ({
142142
info={buttonLabel}
143143
alignment="bottom-center"
144144
placement="floating"
145-
hasRepetitiveLabel
146145
>
147146
<TextButton
148147
aria-controls={collapsibleContentId}

packages/gamut/src/Button/IconButton.tsx

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ComponentProps, forwardRef, useId } from 'react';
1+
import { ComponentProps, forwardRef } from 'react';
22

33
import { ButtonBaseElements } from '../ButtonBase/ButtonBase';
44
import { ToolTip, ToolTipProps } from '../Tip/ToolTip';
@@ -19,10 +19,7 @@ export type IconButtonProps = ComponentProps<typeof IconButtonBase> &
1919
IconComponentType & {
2020
'aria-label'?: string;
2121
tip: string;
22-
tipProps?: Omit<
23-
ToolTipProps,
24-
'info' | 'id' | 'children' | 'hasRepetitiveLabel'
25-
>;
22+
tipProps?: Omit<ToolTipProps, 'info' | 'children'>;
2623
};
2724

2825
export const IconButton = forwardRef<ButtonBaseElements, IconButtonProps>(
@@ -38,30 +35,15 @@ export const IconButton = forwardRef<ButtonBaseElements, IconButtonProps>(
3835
},
3936
ref
4037
) => {
41-
const tipId = useId();
42-
43-
const firstWord = tip?.split(' ')[0] ?? tip;
44-
45-
const hasRepetitiveLabel =
46-
ariaLabel?.toLowerCase() === firstWord?.toLowerCase() || !ariaLabel;
47-
48-
const trueAriaLabel = ariaLabel ?? firstWord;
49-
5038
const buttonSize = size || 'normal';
5139

5240
const iconSize = iconSizeMapping[buttonSize];
5341

5442
return (
55-
<ToolTip
56-
info={tip}
57-
id={tipId}
58-
hasRepetitiveLabel={hasRepetitiveLabel}
59-
{...(tipProps as any)}
60-
>
43+
<ToolTip info={tip} {...(tipProps as any)}>
6144
<IconButtonBase
6245
{...props}
63-
aria-describedby={tipId}
64-
aria-label={trueAriaLabel}
46+
aria-label={ariaLabel || tip}
6547
ref={ref}
6648
size={size}
6749
variant={variant}

packages/gamut/src/Button/__tests__/IconButton.test.tsx

Lines changed: 14 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@ import { setupRtl } from 'component-test-setup';
66
import { IconButton } from '../IconButton';
77
import { IconButtonFloatingMock } from './mocks';
88

9-
const label = 'Click';
9+
const label = 'Aria gonna click this button?';
1010
const tip = 'Click this button';
11-
const tipText = 'this button';
12-
const uniqueTip = 'I am not repetitive text';
1311

1412
const onClick = jest.fn();
1513
const buttonProps = {
@@ -39,55 +37,37 @@ describe('IconButton', () => {
3937
view.getByRole('img', { hidden: true });
4038
});
4139

42-
// TO-DO: When we upgrade jest, we can use `description` in the tests below to make sure they are semantically connected to buttons.
43-
it('renders a tip with repetition removed', async () => {
40+
it('renders the tip text from the tip prop', async () => {
4441
const { view } = renderView({});
4542

46-
const button = view.getByRole('button', { name: label });
43+
view.getByRole('button', { name: label });
4744

48-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
49-
// @ts-ignore: We need to update the rest of the testing suite to use the correct types (which are reliant on upgrading Node)
50-
expect(button).toHaveAccessibleDescription(tipText);
51-
expect(view.getByRole('tooltip', { hidden: true })).toHaveTextContent(
52-
tipText
53-
);
45+
expect(view.getByRole('tooltip', { hidden: true })).toHaveTextContent(tip);
5446
});
5547

56-
it('renders a tip with both labels when they are not repetitive', async () => {
57-
const { view } = renderView({ tip: uniqueTip });
48+
it('sets the aria-label as the tip when only the tip prop is provided', async () => {
49+
const { view } = renderView({ 'aria-label': '' });
5850

59-
view.getByRole('button', { name: label });
60-
expect(view.getByRole('tooltip', { hidden: true })).toHaveTextContent(
61-
uniqueTip
62-
);
51+
view.getByRole('button', { name: tip });
52+
expect(view.getByRole('tooltip', { hidden: true })).toHaveTextContent(tip);
6353
});
6454

65-
it('renders a true aria-label based on tip when aria-label is not defined', async () => {
66-
const { view } = renderView({ 'aria-label': undefined });
55+
it('sets the aria-label text from the aria-label prop when both the tip and aria-label is provided', async () => {
56+
const { view } = renderView({ 'aria-label': '' });
6757

68-
view.getByRole('button', { name: label });
69-
expect(view.getByRole('tooltip', { hidden: true })).toHaveTextContent(
70-
tipText
71-
);
58+
view.getByRole('button', { name: tip });
59+
expect(view.getByRole('tooltip', { hidden: true })).toHaveTextContent(tip);
7260
});
7361

7462
it('renders a floating tip', async () => {
7563
const { view } = renderFloatingView({});
7664

77-
expect(view.getByRole('tooltip', { hidden: true })).toHaveTextContent(
78-
tipText
79-
);
80-
81-
expect(view.queryByText(tip)).toBeNull();
65+
expect(view.queryAllByText(tip).length).toBe(1);
8266

8367
const cta = view.getByRole('button', { name: label });
8468

85-
expect(view.queryByText('tooltip')).toBeNull();
86-
8769
await userEvent.hover(cta);
8870

89-
await waitFor(() => {
90-
view.getByText(tip);
91-
});
71+
await waitFor(() => expect(view.queryAllByText(tip).length).toBe(2));
9272
});
9373
});

packages/gamut/src/Menu/__tests__/Menu.test.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { MultipleUsersIcon } from '@codecademy/gamut-icons';
22
import { setupRtl } from '@codecademy/gamut-tests';
3-
import { screen } from '@testing-library/react';
3+
import { screen, waitFor } from '@testing-library/react';
4+
import userEvent from '@testing-library/user-event';
45

56
import { Menu } from '../Menu';
67
import { MenuItem } from '../MenuItem';
@@ -123,10 +124,12 @@ describe('Menu', () => {
123124
),
124125
});
125126

126-
view.getByLabelText(label);
127-
expect(view.getByRole('tooltip', { hidden: true })).toHaveTextContent(
128-
label
129-
);
127+
const menuItem = view.getByLabelText(label);
128+
await userEvent.hover(menuItem);
129+
130+
await waitFor(() => {
131+
view.getByText(label);
132+
});
130133
});
131134

132135
it('render an aria-label for non-interactive menu items with a label', async () => {

packages/gamut/src/ModalDeprecated/__tests__/Modal.test.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,12 @@ describe('ModalDeprecated', () => {
3333
children: <button type="button">Click Me</button>,
3434
});
3535

36-
expect(screen.queryByLabelText('Close')).not.toBeInTheDocument();
36+
expect(screen.queryByLabelText('Close modal')).not.toBeInTheDocument();
3737
});
3838

3939
it('renders its close button if hideDefaultCloseButton is false', () => {
4040
renderModal();
41-
42-
expect(screen.queryByLabelText('Close')).toBeInTheDocument();
41+
expect(screen.queryByLabelText('Close modal')).toBeInTheDocument();
4342
});
4443

4544
it('triggers onRequestClose callback when escape key is triggered', () => {

0 commit comments

Comments
 (0)