Skip to content

Commit d4fddba

Browse files
committed
CR changes v3
1 parent 64c5abd commit d4fddba

3 files changed

Lines changed: 18 additions & 3 deletions

File tree

packages/design-system/src/components/ds-button/versions/ds-button-v3/__tests__/ds-button-v3.browser.test.tsx

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,11 +173,11 @@ describe('DsButtonV3', () => {
173173
expect(ref.current?.textContent).toBe('Ref');
174174
});
175175

176-
it('is disabled and keeps normal colors when loading', async () => {
176+
it('loading without disabled keeps normal colors', async () => {
177177
const onClick = vi.fn();
178178

179179
await page.render(
180-
<DsButtonV3 loading disabled={false} onClick={onClick}>
180+
<DsButtonV3 loading onClick={onClick}>
181181
Saving
182182
</DsButtonV3>,
183183
);
@@ -190,6 +190,20 @@ describe('DsButtonV3', () => {
190190
expect(onClick).not.toHaveBeenCalled();
191191
});
192192

193+
it('loading + disabled shows spinner with disabled styling', async () => {
194+
await page.render(
195+
<DsButtonV3 loading disabled>
196+
Saving
197+
</DsButtonV3>,
198+
);
199+
200+
const button = page.getByRole('button', { name: 'Saving', disabled: true });
201+
202+
await expect.element(button).toBeDisabled();
203+
await expect.element(button).not.toHaveClass(styles.loading);
204+
await expect.element(button).toHaveAttribute('aria-busy', 'true');
205+
});
206+
193207
it('selected + disabled does not remove selected styling', async () => {
194208
await page.render(
195209
<DsButtonV3 selected disabled>

packages/design-system/src/components/ds-button/versions/ds-button-v3/ds-button-v3.stories.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const meta: Meta<typeof DsButtonV3> = {
1717
size: { control: 'select', options: buttonV3Sizes },
1818
onDark: { control: 'boolean' },
1919
loading: { control: 'boolean' },
20+
disabled: { control: 'boolean' },
2021
className: { table: { disable: true } },
2122
style: { table: { disable: true } },
2223
ref: { table: { disable: true } },

packages/design-system/src/components/ds-button/versions/ds-button-v3/ds-button-v3.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ const DsButtonV3 = ({
4848
className={classNames(
4949
styles.root,
5050
sizeClassMap[size],
51-
{ [styles.iconOnly]: isIconOnly, [styles.loading]: loading },
51+
{ [styles.iconOnly]: isIconOnly, [styles.loading]: loading && !disabled },
5252
className,
5353
)}
5454
style={style}

0 commit comments

Comments
 (0)