Skip to content
Open
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
- `<SimpleDialog />`
- `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
- `<SuggestField />` accepts `searchContextKey` to refresh suggestions when the search context changes.
- `<ActivityControlWidget />` forwards action `aria-label` and `aria-pressed` to its buttons.
- `<SearchField />` accepts `clearButtonAriaLabel` to name the clear button.

### Changed

Expand Down Expand Up @@ -47,6 +49,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p

### Fixed

- `<IconButton />` uses `text` as its default accessible name. Explicit ARIA labels take precedence.
- `<CodeEditor />` keeps dialogs open when Escape releases Tab for keyboard navigation. The navigation hint is shown only when the editor captures Tab.
- `<CodeAutocompleteField />` keeps the surrounding dialog open when Escape dismisses suggestions.

Expand Down
5 changes: 4 additions & 1 deletion src/cmem/ActivityControl/ActivityControlWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ interface IActivityContextMenu extends TestableComponent {
menuItems: IActivityMenuAction[];
}

export interface ActivityControlWidgetAction extends TestableComponent {
export interface ActivityControlWidgetAction
extends TestableComponent, Pick<React.AriaAttributes, "aria-label" | "aria-pressed"> {
// The action that should be triggered
action: () => void;
// The tooltip that should be shown over the action icon on hover
Expand Down Expand Up @@ -277,6 +278,8 @@ const ActivityActionButton = ({ action }: ActivityActionButtonProps) => {
<IconButton
data-test-id={action["data-test-id"]}
data-testid={action["data-testid"]}
aria-label={action["aria-label"]}
aria-pressed={action["aria-pressed"]}
name={action.icon}
text={action.tooltip}
onClick={action.action}
Expand Down
13 changes: 13 additions & 0 deletions src/cmem/ActivityControl/tests/ActivityControlWidget.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,19 @@ import { IconButton, Tag, TagList } from "../../../index";
import { ActivityControlWidget, ActivityControlWidgetAction } from "../ActivityControlWidget";

describe("ActivityControlWidget", () => {
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(<ActivityControlWidget activityActions={[action]} />);

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();
Expand Down
3 changes: 2 additions & 1 deletion src/components/Icon/IconButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ interface ExtendedButtonProps
*/
name: ValidIconName | string[] | React.ReactElement<TestIconProps>;
/**
* Button text, will be displayed as tooltip.
* Tooltip text and default accessible name for the button.
*/
text?: string;
/**
Expand Down Expand Up @@ -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) ? (
<Icon name={name as IconProps["name"]} {...iconProps} />
Expand Down
4 changes: 4 additions & 0 deletions src/components/TextField/SearchField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ export interface SearchFieldProps extends TestableComponent, Omit<TextFieldProps
* Tooltip to show for the clear button.
*/
onClearanceText?: string;
/** Accessible name for the clear button. */
clearButtonAriaLabel?: string;
}

/**
Expand All @@ -31,6 +33,7 @@ export const SearchField = ({
emptySearchInputMessage = "Enter search term",
onClearanceHandler,
onClearanceText = "Clear current search term",
clearButtonAriaLabel,
onChange,
leftIcon = <Icon name="operation-search" />,
rightElement,
Expand All @@ -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();
Expand Down
Loading