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

Accessibility: Make all components import from ariaLabel instead #7458

Merged
merged 2 commits into from
Dec 19, 2024
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
4 changes: 2 additions & 2 deletions components/lib/multiselect/MultiSelectHeader.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { localeOption } from '../api/Api';
import { ariaLabel } from '../api/Api';
import { Checkbox } from '../checkbox/Checkbox';
import { useMergeProps } from '../hooks/Hooks';
import { CheckIcon } from '../icons/check';
Expand Down Expand Up @@ -158,7 +158,7 @@ export const MultiSelectHeader = React.memo((props) => {
{
type: 'button',
className: cx('closeButton'),
'aria-label': localeOption('close'),
'aria-label': ariaLabel('close'),
onClick: props.onClose
},
getPTOptions('closeButton')
Expand Down
5 changes: 2 additions & 3 deletions components/lib/overlaypanel/OverlayPanel.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import PrimeReact, { PrimeReactContext, localeOption } from '../api/Api';
import PrimeReact, { PrimeReactContext, ariaLabel } from '../api/Api';
import { useHandleStyle } from '../componentbase/ComponentBase';
import { CSSTransition } from '../csstransition/CSSTransition';
import { ESC_KEY_HANDLING_PRIORITIES, useDisplayOrder, useGlobalOnEscapeKey, useMergeProps, useMountEffect, useOverlayListener, useUnmountEffect } from '../hooks/Hooks';
Expand Down Expand Up @@ -239,13 +239,12 @@ export const OverlayPanel = React.forwardRef((inProps, ref) => {
);
const icon = props.closeIcon || <TimesIcon {...closeIconProps} />;
const closeIcon = IconUtils.getJSXIcon(icon, { ...closeIconProps }, { props });
const ariaLabel = props.ariaCloseLabel || localeOption('close');
const closeButtonProps = mergeProps(
{
type: 'button',
className: cx('closeButton'),
onClick: (e) => onCloseClick(e),
'aria-label': ariaLabel
'aria-label': props.ariaCloseLabel || ariaLabel('close')
},
ptm('closeButton')
);
Expand Down
5 changes: 2 additions & 3 deletions components/lib/sidebar/Sidebar.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import PrimeReact, { PrimeReactContext, localeOption } from '../api/Api';
import PrimeReact, { PrimeReactContext, ariaLabel } from '../api/Api';
import { useHandleStyle } from '../componentbase/ComponentBase';
import { CSSTransition } from '../csstransition/CSSTransition';
import { ESC_KEY_HANDLING_PRIORITIES, useDisplayOrder, useEventListener, useGlobalOnEscapeKey, useMergeProps, useMountEffect, useUnmountEffect, useUpdateEffect } from '../hooks/Hooks';
Expand Down Expand Up @@ -160,14 +160,13 @@ export const Sidebar = React.forwardRef((inProps, ref) => {
});

const createCloseIcon = () => {
const ariaLabel = props.ariaCloseLabel || localeOption('close');
const closeButtonProps = mergeProps(
{
type: 'button',
ref: closeIconRef,
className: cx('closeButton'),
onClick: (e) => onClose(e),
'aria-label': ariaLabel
'aria-label': props.ariaCloseLabel || ariaLabel('close')
},
ptm('closeButton')
);
Expand Down
5 changes: 2 additions & 3 deletions components/lib/toast/ToastMessage.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { localeOption } from '../api/Locale';
import { ariaLabel } from '../api/Api';
import { useMergeProps, useTimeout } from '../hooks/Hooks';
import { CheckIcon } from '../icons/check';
import { ExclamationTriangleIcon } from '../icons/exclamationtriangle';
Expand Down Expand Up @@ -88,14 +88,13 @@ export const ToastMessage = React.memo(

const icon = _closeIcon || <TimesIcon {...buttonIconProps} />;
const closeIcon = IconUtils.getJSXIcon(icon, { ...buttonIconProps }, { props });
const ariaLabel = props.ariaCloseLabel || localeOption('close');

const closeButtonProps = mergeProps(
{
type: 'button',
className: cx('message.closeButton'),
onClick: onClose,
'aria-label': ariaLabel
'aria-label': props.ariaCloseLabel || ariaLabel('close')
},
getPTOptions('closeButton', parentParams),
ptmo(pt, 'closeButton', { ...params, hostName: props.hostName })
Expand Down
4 changes: 2 additions & 2 deletions components/lib/treeselect/TreeSelect.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import PrimeReact, { PrimeReactContext, localeOption } from '../api/Api';
import PrimeReact, { PrimeReactContext, localeOption, ariaLabel } from '../api/Api';
import { useHandleStyle } from '../componentbase/ComponentBase';
import { useMergeProps, useMountEffect, useOverlayListener, useUnmountEffect, useUpdateEffect } from '../hooks/Hooks';
import { ChevronDownIcon } from '../icons/chevrondown';
Expand Down Expand Up @@ -770,7 +770,7 @@ export const TreeSelect = React.memo(
className: cx('closeButton'),
onKeyDown: (event) => onHeaderElementKeyDown(event, true),
onClick: hide,
'aria-label': localeOption('close')
'aria-label': ariaLabel('close')
},
ptm('closeButton')
);
Expand Down
Loading