Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Spinner): remove auto-converting aria-label #6167

Merged
merged 1 commit into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,8 @@ export const PullToRefresh = ({
return (
<TouchRootContext.Provider value={true}>
<Touch
aria-live="polite"
aria-busy={!!isFetching}
{...restProps}
onStart={onTouchStart}
onMove={onTouchMove}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as React from 'react';
import { classNames } from '@vkontakte/vkjs';
import { HTMLAttributesWithRootRef } from '../../types';
import { RootComponent } from '../RootComponent/RootComponent';
import { VisuallyHidden } from '../VisuallyHidden/VisuallyHidden';
import styles from './PullToRefresh.module.css';

function calcStrokeDashOffset(value: number, radius: number) {
Expand All @@ -21,7 +22,7 @@ export const PullToRefreshSpinner = ({
size = 24,
strokeWidth = 2.5,
progress = 0,
'aria-label': ariaLabel = 'Пожалуйста, подождите...',
children = 'Пожалуйста, подождите...',
...restProps
}: PullToRefreshSpinnerProps) => {
const radius = 0.5 * size - 0.5 * strokeWidth;
Expand All @@ -36,9 +37,9 @@ export const PullToRefreshSpinner = ({
styles['PullToRefresh__spinner'],
on && styles['PullToRefresh__spinner--on'],
)}
aria-label={on ? ariaLabel : undefined}
{...restProps}
>
{on && <VisuallyHidden>{children}</VisuallyHidden>}
<svg
role="presentation"
className={styles['PullToRefresh__spinner-self']}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ export const ScreenSpinner = ({
className,
state = 'loading',
size = 'large',
'aria-label': ariaLabel = 'Пожалуйста, подождите...',
onClick,
children = 'Пожалуйста, подождите...',
...restProps
}: ScreenSpinnerProps) => {
const hideSpinner = state === 'done' || state === 'error';
Expand Down Expand Up @@ -52,9 +52,10 @@ export const ScreenSpinner = ({
hideSpinner && styles['ScreenSpinner__spinner--hidden'],
)}
size={size}
aria-label={ariaLabel}
{...restProps}
/>
>
{children}
</Spinner>
<div
className={classNames(
styles['ScreenSpinner__icon'],
Expand Down
3 changes: 2 additions & 1 deletion packages/vkui/src/components/Spinner/Spinner.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as React from 'react';
import { Icon16Spinner, Icon24Spinner, Icon32Spinner, Icon44Spinner } from '@vkontakte/icons';
import { hasReactNode } from '@vkontakte/vkjs';
import { HTMLAttributesWithRootRef } from '../../types';
import { RootComponent } from '../RootComponent/RootComponent';
import { VisuallyHidden } from '../VisuallyHidden/VisuallyHidden';
Expand Down Expand Up @@ -56,7 +57,7 @@ export const Spinner = React.memo(
/>
)}
</SpinnerIcon>
<VisuallyHidden>{children}</VisuallyHidden>
{hasReactNode(children) && <VisuallyHidden>{children}</VisuallyHidden>}
</RootComponent>
);
},
Expand Down
Loading