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

Fix #3280: ARIA add close/clear labels #3281

Merged
merged 1 commit into from
Sep 10, 2022
Merged
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
Fix #3280: ARIA add close/clear labels
  • Loading branch information
melloware committed Sep 10, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 3cf2e39e340c280dcb5f5b84d2fa982b05d14c3d
13 changes: 5 additions & 8 deletions components/lib/dialog/Dialog.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as React from 'react';
import PrimeReact from '../api/Api';
import PrimeReact, { localeOption } from '../api/Api';
import { Button } from '../button/Button';
import { CSSTransition } from '../csstransition/CSSTransition';
import { useEventListener, useMountEffect, useUnmountEffect, useUpdateEffect } from '../hooks/Hooks';
import { Portal } from '../portal/Portal';
@@ -407,12 +408,8 @@ export const Dialog = React.forwardRef((props, ref) => {

const createCloseIcon = () => {
if (props.closable) {
return (
<button ref={closeRef} type="button" className="p-dialog-header-icon p-dialog-header-close p-link" aria-label={props.ariaCloseIconLabel} onClick={onClose}>
<span className="p-dialog-header-close-icon pi pi-times"></span>
<Ripple />
</button>
);
const ariaLabel = props.ariaCloseIconLabel || localeOption('close');
return <Button ref={closeRef} type="button" className="p-dialog-header-icon p-dialog-header-close p-link" icon="p-dialog-header-close-icon pi pi-times" onClick={onClose} aria-label={ariaLabel} />;
}

return null;
@@ -576,7 +573,7 @@ Dialog.defaultProps = {
maximizable: false,
blockScroll: false,
icons: null,
ariaCloseIconLabel: 'Close',
ariaCloseIconLabel: null,
focusOnShow: true,
minX: 0,
minY: 0,
5 changes: 3 additions & 2 deletions components/lib/dropdown/DropdownPanel.js
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ import * as React from 'react';
import { localeOption } from '../api/Api';
import { CSSTransition } from '../csstransition/CSSTransition';
import { Portal } from '../portal/Portal';
import { classNames, ObjectUtils, DomHandler } from '../utils/Utils';
import { classNames, DomHandler, ObjectUtils } from '../utils/Utils';
import { VirtualScroller } from '../virtualscroller/VirtualScroller';
import { DropdownItem } from './DropdownItem';

@@ -93,7 +93,8 @@ export const DropdownPanel = React.memo(

const createFilterClearIcon = () => {
if (props.showFilterClear && props.filterValue) {
return <i className="p-dropdown-filter-clear-icon pi pi-times" onClick={() => props.onFilterClearIconClick(() => DomHandler.focus(filterInputRef.current))}></i>;
const ariaLabel = localeOption('clear');
return <i className="p-dropdown-filter-clear-icon pi pi-times" aria-label={ariaLabel} onClick={() => props.onFilterClearIconClick(() => DomHandler.focus(filterInputRef.current))}></i>;
}

return null;
11 changes: 3 additions & 8 deletions components/lib/galleria/Galleria.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import * as React from 'react';
import PrimeReact from '../api/Api';
import PrimeReact, { localeOption } from '../api/Api';
import { Button } from '../button/Button';
import { CSSTransition } from '../csstransition/CSSTransition';
import { useInterval, useUnmountEffect } from '../hooks/Hooks';
import { Portal } from '../portal/Portal';
import { Ripple } from '../ripple/Ripple';
import { classNames, DomHandler, ObjectUtils, ZIndexUtils } from '../utils/Utils';
import { GalleriaItem } from './GalleriaItem';
import { GalleriaThumbnails } from './GalleriaThumbnails';
@@ -148,12 +148,7 @@ export const Galleria = React.memo(
indicatorPosClassName
);

const closeIcon = props.fullScreen && (
<button type="button" className="p-galleria-close p-link" onClick={hide}>
<span className="p-galleria-close-icon pi pi-times"></span>
<Ripple />
</button>
);
const closeIcon = props.fullScreen && <Button type="button" className="p-galleria-close p-link" icon="p-galleria-close-icon pi pi-times" onClick={hide} aria-label={localeOption('close')} />;

const header = createHeader();
const footer = createFooter();
4 changes: 2 additions & 2 deletions components/lib/image/Image.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import PrimeReact from '../api/Api';
import PrimeReact, { localeOption } from '../api/Api';
import { CSSTransition } from '../csstransition/CSSTransition';
import { useUnmountEffect } from '../hooks/Hooks';
import { Portal } from '../portal/Portal';
@@ -130,7 +130,7 @@ export const Image = React.memo(
<button className="p-image-action p-link" onClick={zoomIn} type="button" disabled={zoomDisabled}>
<i className="pi pi-search-plus"></i>
</button>
<button className="p-image-action p-link" type="button">
<button className="p-image-action p-link" type="button" aria-label={localeOption('close')}>
<i className="pi pi-times"></i>
</button>
</div>
3 changes: 2 additions & 1 deletion components/lib/inplace/Inplace.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as React from 'react';
import { localeOption } from '../api/Api';
import { Button } from '../button/Button';
import { classNames, ObjectUtils } from '../utils/Utils';

@@ -65,7 +66,7 @@ export const Inplace = React.forwardRef((props, ref) => {

const createCloseButton = () => {
if (props.closable) {
return <Button type="button" className="p-inplace-content-close" icon="pi pi-times" onClick={close} />;
return <Button type="button" className="p-inplace-content-close" icon="pi pi-times" onClick={close} ariaLabel={localeOption('close')} />;
}

return null;
11 changes: 4 additions & 7 deletions components/lib/messages/UIMessage.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as React from 'react';
import { localeOption } from '../api/Api';
import { Button } from '../button/Button';
import { useTimeout } from '../hooks/Hooks';
import { Ripple } from '../ripple/Ripple';
import { classNames, IconUtils } from '../utils/Utils';

export const UIMessage = React.memo(
@@ -31,12 +32,8 @@ export const UIMessage = React.memo(

const createCloseIcon = () => {
if (closable !== false) {
return (
<button type="button" className="p-message-close p-link" onClick={onClose}>
<i className="p-message-close-icon pi pi-times"></i>
<Ripple />
</button>
);
const ariaLabel = localeOption('close');
return <Button type="button" className="p-message-close p-link" icon="p-message-close-icon pi pi-times" onClick={onClose} aria-label={ariaLabel} />;
}

return null;
12 changes: 4 additions & 8 deletions components/lib/multiselect/MultiSelectHeader.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import * as React from 'react';
import { localeOption } from '../api/Api';
import { Button } from '../button/Button';
import { Checkbox } from '../checkbox/Checkbox';
import { InputText } from '../inputtext/InputText';
import { Ripple } from '../ripple/Ripple';
import { ObjectUtils, classNames } from '../utils/Utils';
import { classNames, ObjectUtils } from '../utils/Utils';

export const MultiSelectHeader = React.memo((props) => {
const filterOptions = {
@@ -61,12 +62,7 @@ export const MultiSelectHeader = React.memo((props) => {

const filterElement = createFilterElement();
const checkboxElement = props.showSelectAll && <Checkbox checked={props.selectAll} onChange={onSelectAll} role="checkbox" aria-checked={props.selectAll} />;
const closeElement = (
<button type="button" className="p-multiselect-close p-link" onClick={props.onClose}>
<span className="p-multiselect-close-icon pi pi-times"></span>
<Ripple />
</button>
);
const closeElement = <Button type="button" className="p-multiselect-close p-link" icon="p-multiselect-close-icon pi pi-times" onClick={props.onClose} aria-label={localeOption('close')} />;
const element = (
<div className="p-multiselect-header">
{checkboxElement}
14 changes: 5 additions & 9 deletions components/lib/overlaypanel/OverlayPanel.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import * as React from 'react';
import PrimeReact from '../api/Api';
import PrimeReact, { localeOption } from '../api/Api';
import { Button } from '../button/Button';
import { CSSTransition } from '../csstransition/CSSTransition';
import { useMountEffect, useOverlayListener, useUnmountEffect } from '../hooks/Hooks';
import { OverlayService } from '../overlayservice/OverlayService';
import { Portal } from '../portal/Portal';
import { Ripple } from '../ripple/Ripple';
import { classNames, DomHandler, ObjectUtils, UniqueComponentId, ZIndexUtils } from '../utils/Utils';

export const OverlayPanel = React.forwardRef((props, ref) => {
@@ -184,12 +184,8 @@ export const OverlayPanel = React.forwardRef((props, ref) => {

const createCloseIcon = () => {
if (props.showCloseIcon) {
return (
<button type="button" className="p-overlaypanel-close p-link" onClick={onCloseClick} aria-label={props.ariaCloseLabel}>
<span className="p-overlaypanel-close-icon pi pi-times"></span>
<Ripple />
</button>
);
const ariaLabel = props.ariaCloseLabel || localeOption('close');
return <Button type="button" className="p-overlaypanel-close p-link" icon="p-overlaypanel-close-icon pi pi-times" onClick={onCloseClick} aria-label={ariaLabel} />;
}

return null;
@@ -238,7 +234,7 @@ OverlayPanel.defaultProps = {
className: null,
appendTo: null,
breakpoints: null,
ariaCloseLabel: 'close',
ariaCloseLabel: null,
transitionOptions: null,
onShow: null,
onHide: null
14 changes: 5 additions & 9 deletions components/lib/sidebar/Sidebar.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import * as React from 'react';
import PrimeReact from '../api/Api';
import PrimeReact, { localeOption } from '../api/Api';
import { Button } from '../button/Button';
import { CSSTransition } from '../csstransition/CSSTransition';
import { useEventListener, useMountEffect, useUnmountEffect, useUpdateEffect } from '../hooks/Hooks';
import { Portal } from '../portal/Portal';
import { Ripple } from '../ripple/Ripple';
import { classNames, DomHandler, ObjectUtils, ZIndexUtils } from '../utils/Utils';

export const Sidebar = React.forwardRef((props, ref) => {
@@ -146,12 +146,8 @@ export const Sidebar = React.forwardRef((props, ref) => {

const createCloseIcon = () => {
if (props.showCloseIcon) {
return (
<button type="button" ref={closeIconRef} className="p-sidebar-close p-sidebar-icon p-link" onClick={onClose} aria-label={props.ariaCloseLabel}>
<span className="p-sidebar-close-icon pi pi-times" />
<Ripple />
</button>
);
const ariaLabel = props.ariaCloseLabel || localeOption('close');
return <Button ref={closeIconRef} type="button" className="p-sidebar-close p-sidebar-icon p-link" icon="p-sidebar-close-icon pi pi-times" onClick={onClose} aria-label={ariaLabel} />;
}

return null;
@@ -223,7 +219,7 @@ Sidebar.defaultProps = {
baseZIndex: 0,
dismissable: true,
showCloseIcon: true,
ariaCloseLabel: 'close',
ariaCloseLabel: null,
closeOnEscape: true,
icons: null,
modal: true,
9 changes: 2 additions & 7 deletions components/lib/treeselect/TreeSelect.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as React from 'react';
import PrimeReact, { localeOption } from '../api/Api';
import { Button } from '../button/Button';
import { useMountEffect, useOverlayListener, useUnmountEffect, useUpdateEffect } from '../hooks/Hooks';
import { OverlayService } from '../overlayservice/OverlayService';
import { Ripple } from '../ripple/Ripple';
import { Tree } from '../tree/Tree';
import { classNames, DomHandler, ObjectUtils, ZIndexUtils } from '../utils/Utils';
import { TreeSelectPanel } from './TreeSelectPanel';
@@ -467,12 +467,7 @@ export const TreeSelect = React.memo(

const createHeader = () => {
const filterElement = createFilterElement();
const closeElement = (
<button type="button" className="p-treeselect-close p-link" onClick={hide}>
<span className="p-treeselect-close-icon pi pi-times"></span>
<Ripple />
</button>
);
const closeElement = <Button type="button" className="p-treeselect-close p-link" icon="p-treeselect-close-icon pi pi-times" onClick={hide} aria-label={localeOption('close')} />;
const content = (
<div className="p-treeselect-header">
{filterElement}