Skip to content

Commit aca203f

Browse files
fixup! Fix(web-react): Use aria-label on buttons instead ariaLabel prop #DS-1879
1 parent d93b185 commit aca203f

File tree

7 files changed

+24
-24
lines changed

7 files changed

+24
-24
lines changed

packages/web-react/src/components/Button/Button.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { useStyleProps } from '../../hooks';
66
import { SpiritButtonProps } from '../../types';
77
import { mergeStyleProps } from '../../utils';
88
import { Spinner } from '../Spinner';
9-
import { useButtonAriaProps } from './useButtonAriaProps';
9+
import { useButtonProps } from './useButtonProps';
1010
import { useButtonStyleProps } from './useButtonStyleProps';
1111

1212
const defaultProps: Partial<SpiritButtonProps> = {
@@ -34,7 +34,7 @@ const _Button = <T extends ElementType = 'button', C = void, S = void>(
3434
...restProps
3535
} = propsWithDefaults;
3636

37-
const { buttonProps } = useButtonAriaProps(restProps);
37+
const { buttonProps } = useButtonProps(restProps);
3838
const { classProps, props: modifiedProps } = useButtonStyleProps(restProps);
3939
const { styleProps, props: otherProps } = useStyleProps(modifiedProps);
4040
const mergedStyleProps = mergeStyleProps(ElementTag, { classProps, styleProps, otherProps });
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
'use client';
22

3-
export * from './useButtonAriaProps';
3+
export * from './useButtonProps';
44
export * from './useButtonStyleProps';
55
export { default as Button } from './Button';
66

77
// Export ButtonLink here for backwards compatibility
88
// ButtonLink is NOT exported from packages/web-react/src/components/index.ts
99
// ButtonLink will be removed in a future release and Button should be used instead
1010
// [web-react: Polymorfní Button](https://jira.lmc.cz/browse/DS-978)
11-
export * from '../ButtonLink/useButtonLinkAriaProps';
11+
export * from '../ButtonLink/useButtonLinkProps';
1212
export * from '../ButtonLink/useButtonLinkStyleProps';
1313
export { default as ButtonLink } from '../ButtonLink/ButtonLink';

packages/web-react/src/components/Button/useButtonAriaProps.ts renamed to packages/web-react/src/components/Button/useButtonProps.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ const handleClick = (event: ClickEvent, isDisabled?: boolean, onClick?: (event:
1212
}
1313
};
1414

15-
export type UseButtonAriaProps = Partial<SpiritButtonProps>;
16-
export type UseButtonAriaReturn = {
17-
buttonProps: UseButtonAriaProps;
15+
export type UseButtonProps = Partial<SpiritButtonProps>;
16+
export type UseButtonReturn = {
17+
buttonProps: UseButtonProps;
1818
};
1919

20-
export const useButtonAriaProps = (props: UseButtonAriaProps): UseButtonAriaReturn => {
20+
export const useButtonProps = (props: UseButtonProps): UseButtonReturn => {
2121
const { isDisabled, isLoading, onClick, type = 'button' } = props;
2222

2323
const additionalProps = {

packages/web-react/src/components/ButtonLink/ButtonLink.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { useStyleProps } from '../../hooks';
55
import { SpiritButtonLinkProps } from '../../types';
66
import { mergeStyleProps } from '../../utils';
77
import { Spinner } from '../Spinner';
8-
import { useButtonLinkAriaProps } from './useButtonLinkAriaProps';
8+
import { useButtonLinkProps } from './useButtonLinkProps';
99
import { useButtonLinkStyleProps } from './useButtonLinkStyleProps';
1010

1111
const defaultProps: Partial<SpiritButtonLinkProps> = {
@@ -31,7 +31,7 @@ const _ButtonLink = <T extends ElementType = 'a', C = void, S = void>(
3131
...restProps
3232
} = propsWithDefaults;
3333

34-
const { buttonLinkProps } = useButtonLinkAriaProps(propsWithDefaults);
34+
const { buttonLinkProps } = useButtonLinkProps(propsWithDefaults);
3535
const { classProps, props: modifiedProps } = useButtonLinkStyleProps(restProps);
3636
const { styleProps, props: otherProps } = useStyleProps(modifiedProps);
3737
const mergedStyleProps = mergeStyleProps(ElementTag, { classProps, styleProps, otherProps });

packages/web-react/src/components/ButtonLink/__tests__/useButtonLinkAriaProps.test.ts renamed to packages/web-react/src/components/ButtonLink/__tests__/useButtonLinkProps.test.ts

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { renderHook } from '@testing-library/react';
2-
import { UseButtonLinkAriaProps, useButtonLinkAriaProps } from '../useButtonLinkAriaProps';
2+
import { UseButtonLinkProps, useButtonLinkProps } from '../useButtonLinkProps';
33

44
describe('useButtonAriaProps', () => {
55
it('should return aria props for anchor tag', () => {
@@ -9,8 +9,8 @@ describe('useButtonAriaProps', () => {
99
isDisabled: false,
1010
target: '_blank',
1111
rel: 'noopener',
12-
} as UseButtonLinkAriaProps;
13-
const { result } = renderHook(() => useButtonLinkAriaProps(props));
12+
} as UseButtonLinkProps;
13+
const { result } = renderHook(() => useButtonLinkProps(props));
1414

1515
expect(result.current.buttonLinkProps).toEqual({
1616
'aria-label': undefined,
@@ -30,8 +30,8 @@ describe('useButtonAriaProps', () => {
3030
isDisabled: true,
3131
target: '_blank',
3232
rel: 'noopener',
33-
} as UseButtonLinkAriaProps;
34-
const { result } = renderHook(() => useButtonLinkAriaProps(props));
33+
} as UseButtonLinkProps;
34+
const { result } = renderHook(() => useButtonLinkProps(props));
3535

3636
expect(result.current.buttonLinkProps).toEqual({
3737
'aria-label': undefined,
@@ -48,8 +48,8 @@ describe('useButtonAriaProps', () => {
4848
const props = {
4949
elementType: 'button',
5050
isDisabled: false,
51-
} as unknown as UseButtonLinkAriaProps;
52-
const { result } = renderHook(() => useButtonLinkAriaProps(props));
51+
} as unknown as UseButtonLinkProps;
52+
const { result } = renderHook(() => useButtonLinkProps(props));
5353

5454
expect(result.current.buttonLinkProps).toEqual({
5555
'aria-label': undefined,
@@ -65,8 +65,8 @@ describe('useButtonAriaProps', () => {
6565
const props = {
6666
elementType: 'button',
6767
isDisabled: true,
68-
} as unknown as UseButtonLinkAriaProps;
69-
const { result } = renderHook(() => useButtonLinkAriaProps(props));
68+
} as unknown as UseButtonLinkProps;
69+
const { result } = renderHook(() => useButtonLinkProps(props));
7070

7171
expect(result.current.buttonLinkProps).toEqual({
7272
'aria-label': undefined,
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
'use client';
22

3-
export * from './useButtonLinkAriaProps';
3+
export * from './useButtonLinkProps';
44
export * from './useButtonLinkStyleProps';
55
export { default as ButtonLink } from './ButtonLink';

packages/web-react/src/components/ButtonLink/useButtonLinkAriaProps.ts renamed to packages/web-react/src/components/ButtonLink/useButtonLinkProps.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ const handleClick = (event: ClickEvent, isDisabled?: boolean, onClick?: (event:
1212
}
1313
};
1414

15-
export type UseButtonLinkAriaProps = Partial<SpiritButtonLinkProps>;
16-
export type UseButtonLinkAriaReturn = {
17-
buttonLinkProps: UseButtonLinkAriaProps;
15+
export type UseButtonLinkProps = Partial<SpiritButtonLinkProps>;
16+
export type UseButtonLinkReturn = {
17+
buttonLinkProps: UseButtonLinkProps;
1818
};
1919

20-
export const useButtonLinkAriaProps = (props: UseButtonLinkAriaProps): UseButtonLinkAriaReturn => {
20+
export const useButtonLinkProps = (props: UseButtonLinkProps): UseButtonLinkReturn => {
2121
const { elementType, isDisabled, isLoading, onClick, href, target, rel } = props;
2222

2323
const additionalProps = {

0 commit comments

Comments
 (0)