diff --git a/components/lib/accordion/Accordion.js b/components/lib/accordion/Accordion.js
index 7483a7ad79..8daf240409 100644
--- a/components/lib/accordion/Accordion.js
+++ b/components/lib/accordion/Accordion.js
@@ -1,4 +1,5 @@
import * as React from 'react';
+import { ariaLabel } from '../api/Api';
import { CSSTransition } from '../csstransition/CSSTransition';
import { useMountEffect } from '../hooks/Hooks';
import { classNames, IconUtils, ObjectUtils, UniqueComponentId } from '../utils/Utils';
@@ -76,10 +77,11 @@ export const Accordion = React.forwardRef((props, ref) => {
const tabIndex = tab.props.disabled ? -1 : null;
const header = tab.props.headerTemplate ? ObjectUtils.getJSXElement(tab.props.headerTemplate, tab.props) : {tab.props.header};
const icon = IconUtils.getJSXIcon(selected ? props.collapseIcon : props.expandIcon, { className: 'p-accordion-toggle-icon' }, { props, selected });
+ const label = selected ? ariaLabel('collapseLabel') : ariaLabel('expandLabel');
return (
-
diff --git a/components/lib/api/Locale.js b/components/lib/api/Locale.js
index 978621867c..9ef62f652d 100644
--- a/components/lib/api/Locale.js
+++ b/components/lib/api/Locale.js
@@ -56,7 +56,9 @@ let locales = {
nextPageLabel: 'Next Page',
previousPageLabel: 'Previous Page',
selectLabel: 'Select',
- unselectLabel: 'Unselect'
+ unselectLabel: 'Unselect',
+ expandLabel: 'Expand',
+ collapseLabel: 'Collapse'
}
}
};
diff --git a/components/lib/datatable/BodyCell.js b/components/lib/datatable/BodyCell.js
index d29a3d969b..96b8582920 100644
--- a/components/lib/datatable/BodyCell.js
+++ b/components/lib/datatable/BodyCell.js
@@ -1,5 +1,6 @@
import * as React from 'react';
import { ariaLabel } from '../api/Api';
+import { Button } from '../button/Button';
import { useEventListener, useUnmountEffect, useUpdateEffect } from '../hooks/Hooks';
import { OverlayService } from '../overlayservice/OverlayService';
import { Ripple } from '../ripple/Ripple';
@@ -524,6 +525,9 @@ export const BodyCell = React.memo((props) => {
} else if (expander) {
const iconClassName = classNames('p-row-toggler-icon', props.expanded ? props.expandedRowIcon : props.collapsedRowIcon);
const ariaControls = `${props.tableSelector}_content_${props.rowIndex}_expanded`;
+ const ariaLabelField = props.selectionAriaLabel || props.tableProps.dataKey;
+ const ariaLabelText = ObjectUtils.resolveFieldData(props.rowData, ariaLabelField);
+ const label = `${props.expanded ? ariaLabel('collapseLabel') : ariaLabel('expandLabel')} ${ariaLabelText}`;
const expanderProps = {
onClick: onRowToggle,
className: 'p-row-toggler p-link',
@@ -531,10 +535,7 @@ export const BodyCell = React.memo((props) => {
};
content = (
-
+
);
if (body) {
diff --git a/components/lib/datatable/RowTogglerButton.js b/components/lib/datatable/RowTogglerButton.js
index 363a99a2c2..acde3b714c 100644
--- a/components/lib/datatable/RowTogglerButton.js
+++ b/components/lib/datatable/RowTogglerButton.js
@@ -1,5 +1,6 @@
import * as React from 'react';
-import { Ripple } from '../ripple/Ripple';
+import { ariaLabel } from '../api/Api';
+import { Button } from '../button/Button';
import { classNames } from '../utils/Utils';
export const RowTogglerButton = React.memo((props) => {
@@ -11,13 +12,9 @@ export const RowTogglerButton = React.memo((props) => {
};
const iconClassName = classNames('p-row-toggler-icon', props.expanded ? props.expandedRowIcon : props.collapsedRowIcon);
+ const label = props.expanded ? ariaLabel('collapseLabel') : ariaLabel('expandLabel');
- return (
-
- );
+ return ;
});
RowTogglerButton.displayName = 'RowTogglerButton';
diff --git a/components/lib/tree/UITreeNode.js b/components/lib/tree/UITreeNode.js
index a4af3b5a13..93a47f6479 100644
--- a/components/lib/tree/UITreeNode.js
+++ b/components/lib/tree/UITreeNode.js
@@ -1,5 +1,6 @@
import * as React from 'react';
-import { Ripple } from '../ripple/Ripple';
+import { ariaLabel } from '../api/Api';
+import { Button } from '../button/Button';
import { classNames, DomHandler, ObjectUtils } from '../utils/Utils';
export const UITreeNode = React.memo((props) => {
@@ -561,13 +562,9 @@ export const UITreeNode = React.memo((props) => {
};
const createToggler = () => {
+ const label = expanded ? ariaLabel('collapseLabel') : ariaLabel('expandLabel');
const iconClassName = classNames('p-tree-toggler-icon pi pi-fw', { 'pi-chevron-right': !expanded, 'pi-chevron-down': expanded });
- let content = (
-
- );
+ let content = ;
if (props.togglerTemplate) {
const defaultContentOptions = {
diff --git a/components/lib/treetable/TreeTableRow.js b/components/lib/treetable/TreeTableRow.js
index 29aa9562f5..6c6a18db92 100644
--- a/components/lib/treetable/TreeTableRow.js
+++ b/components/lib/treetable/TreeTableRow.js
@@ -1,5 +1,6 @@
import * as React from 'react';
-import { Ripple } from '../ripple/Ripple';
+import { ariaLabel } from '../api/Api';
+import { Button } from '../button/Button';
import { classNames, DomHandler } from '../utils/Utils';
import { TreeTableBodyCell } from './TreeTableBodyCell';
@@ -263,15 +264,11 @@ export const TreeTableRow = React.memo((props) => {
};
const createToggler = () => {
+ const label = expanded ? ariaLabel('collapseLabel') : ariaLabel('expandLabel');
const iconClassName = classNames('p-treetable-toggler-icon pi pi-fw', { 'pi-chevron-right': !expanded, 'pi-chevron-down': expanded });
const style = { marginLeft: props.level * 16 + 'px', visibility: props.node.leaf === false || (props.node.children && props.node.children.length) ? 'visible' : 'hidden' };
- return (
-
- );
+ return ;
};
const createCheckbox = () => {
diff --git a/pages/locale/index.js b/pages/locale/index.js
index b35b163100..e0af6dcca5 100644
--- a/pages/locale/index.js
+++ b/pages/locale/index.js
@@ -343,6 +343,14 @@ locale('es');
aria.unselectLabel |
Unselect |
+
+ aria.expandLabel |
+ Expand |
+
+
+ aria.collapseLabel |
+ Collapse |
+