diff --git a/CHANGELOG.md b/CHANGELOG.md
index c782d4f5f..f30a2039d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -14,6 +14,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
- ``
- `fullScreenTogglerTexts` property: sets the texts of the full screen toggler for the `maximize` and `minimize` state, used as `title` and accessible name of the button
- `` accepts `searchContextKey` to refresh suggestions when the search context changes.
+- `` forwards action `aria-label` and `aria-pressed` to its buttons.
+- `` accepts `clearButtonAriaLabel` to name the clear button.
### Changed
@@ -47,6 +49,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
### Fixed
+- `` uses `text` as its default accessible name. Explicit ARIA labels take precedence.
- `` keeps dialogs open when Escape releases Tab for keyboard navigation. The navigation hint is shown only when the editor captures Tab.
- `` keeps the surrounding dialog open when Escape dismisses suggestions.
diff --git a/src/cmem/ActivityControl/ActivityControlWidget.tsx b/src/cmem/ActivityControl/ActivityControlWidget.tsx
index c7fc36e10..89c3e850c 100644
--- a/src/cmem/ActivityControl/ActivityControlWidget.tsx
+++ b/src/cmem/ActivityControl/ActivityControlWidget.tsx
@@ -99,7 +99,8 @@ interface IActivityContextMenu extends TestableComponent {
menuItems: IActivityMenuAction[];
}
-export interface ActivityControlWidgetAction extends TestableComponent {
+export interface ActivityControlWidgetAction
+ extends TestableComponent, Pick {
// The action that should be triggered
action: () => void;
// The tooltip that should be shown over the action icon on hover
@@ -277,6 +278,8 @@ const ActivityActionButton = ({ action }: ActivityActionButtonProps) => {
{
+ it("names icon actions without relying on tooltip text and exposes pressed state", () => {
+ const action = {
+ action: jest.fn(),
+ icon: "item-reload" as const,
+ "aria-label": "Filter results",
+ "aria-pressed": true,
+ tooltip: "Shows only matching results",
+ };
+ render();
+
+ expect(screen.getByRole("button", { name: "Filter results", pressed: true })).toBeInTheDocument();
+ });
+
it("Renders basic widget with actions and handles clicks", () => {
const mockAction1 = jest.fn();
const mockAction2 = jest.fn();
diff --git a/src/components/Icon/IconButton.tsx b/src/components/Icon/IconButton.tsx
index fa57ef972..53a785de5 100644
--- a/src/components/Icon/IconButton.tsx
+++ b/src/components/Icon/IconButton.tsx
@@ -16,7 +16,7 @@ interface ExtendedButtonProps
*/
name: ValidIconName | string[] | React.ReactElement;
/**
- * Button text, will be displayed as tooltip.
+ * Tooltip text and default accessible name for the button.
*/
text?: string;
/**
@@ -71,6 +71,7 @@ export const IconButton = ({
tabIndex={text && !tooltipAsTitle ? -1 : undefined}
title={tooltipAsTitle && text ? text : undefined}
{...restProps}
+ aria-label={restProps["aria-label"] ?? (restProps["aria-labelledby"] ? undefined : text)}
icon={
typeof name === "string" || Array.isArray(name) ? (
diff --git a/src/components/TextField/SearchField.tsx b/src/components/TextField/SearchField.tsx
index eb5ca37f9..b4de7f3b8 100644
--- a/src/components/TextField/SearchField.tsx
+++ b/src/components/TextField/SearchField.tsx
@@ -21,6 +21,8 @@ export interface SearchFieldProps extends TestableComponent, Omit,
rightElement,
@@ -44,6 +47,7 @@ export const SearchField = ({
data-test-id={otherProps["data-test-id"] && `${otherProps["data-test-id"]}-clear-btn`}
name="operation-clear"
text={onClearanceText}
+ aria-label={clearButtonAriaLabel}
onClick={() => {
setValue("");
onClearanceHandler();