Skip to content

Commit

Permalink
Make all components import from ariaLabel instead (#7458)
Browse files Browse the repository at this point in the history
  • Loading branch information
zaguiini authored Dec 19, 2024
1 parent 3bd25db commit 505c4da
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 13 deletions.
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

0 comments on commit 505c4da

Please sign in to comment.