Skip to content

Commit e4550cf

Browse files
committed
smaller fixes for a11y
1 parent da446da commit e4550cf

5 files changed

Lines changed: 31 additions & 22 deletions

File tree

‎src/cmem/ActivityControl/ActivityExecutionErrorReportModal.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ interface ActivityExecutionErrorReportModalProps extends Pick<
1313
* If set, it is used as the accessible name of the dialog via `aria-labelledby`
1414
* (unless `aria-labelledby` is given explicitly), so `aria-label` is ignored.
1515
* Use `aria-label` only for modals without title.
16-
* If neither `title`, `aria-label` nor `aria-labelledby` is set, then "Activity execution error report" is used as `aria-label`.
16+
* If neither `title`, a non-empty `aria-label` nor `aria-labelledby` is set, then "Activity execution error report" is used as `aria-label`.
1717
*/
1818
title?: string;
1919
// Called when the close button is clicked
@@ -61,7 +61,7 @@ export const ActivityExecutionErrorReportModal = ({
6161
return (
6262
<SimpleDialog
6363
title={title}
64-
aria-label={ariaLabel ?? (!title && !ariaLabelledby ? "Activity execution error report" : undefined)}
64+
aria-label={ariaLabel || "Activity execution error report"}
6565
aria-labelledby={ariaLabelledby}
6666
isOpen={true}
6767
size="large"

‎src/cmem/ActivityControl/SilkActivityControl.tsx‎

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ interface IErrorReportAction extends Pick<
100100
* If set, it is used as the accessible name of the dialog via `aria-labelledby`
101101
* (unless `aria-labelledby` is given explicitly), so `aria-label` is ignored.
102102
* Use `aria-label` only for modals without title.
103-
* If neither `title`, `aria-label` nor `aria-labelledby` is set, then `translate("showErrorReport")` is used as `aria-label`.
103+
* If neither `title`, a non-empty `aria-label` nor `aria-labelledby` is set, then `translate("showErrorReport")` is used as `aria-label`.
104104
*/
105105
title?: string;
106106
// The element that will be rendered in the modal, either as Markdown or object
@@ -372,12 +372,7 @@ export function useSilkActivityControl({
372372
{errorReport && failureReportAction && (
373373
<ActivityExecutionErrorReportModal
374374
title={failureReportAction.title}
375-
aria-label={
376-
failureReportAction["aria-label"] ??
377-
(!failureReportAction.title && !failureReportAction["aria-labelledby"]
378-
? translate("showErrorReport")
379-
: undefined)
380-
}
375+
aria-label={failureReportAction["aria-label"] || translate("showErrorReport")}
381376
aria-labelledby={failureReportAction["aria-labelledby"]}
382377
key={"error-report-modal"}
383378
closeButtonValue={failureReportAction.closeButtonValue}

‎src/cmem/ActivityControl/tests/SilkActivityControl.test.tsx‎

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ describe("SilkActivityControl error report", () => {
7575

7676
it("uses the translated `showErrorReport` text as fallback name for a titleless error report dialog", async () => {
7777
const warnSpy = jest.spyOn(console, "warn").mockImplementation(() => undefined);
78-
const { openErrorReport } = renderFailedActivity({ title: "" });
78+
const { openErrorReport } = renderFailedActivity({ title: "", "aria-label": "" });
7979
openErrorReport();
8080
expect(await screen.findByRole("dialog", { name: "showErrorReport" })).toHaveAttribute("aria-modal", "true");
8181
expect(warnSpy).not.toHaveBeenCalled();
@@ -107,16 +107,20 @@ describe("SilkActivityControl error report", () => {
107107
});
108108

109109
describe("ActivityExecutionErrorReportModal", () => {
110-
it("uses an english fallback name if neither title nor aria attributes are given", () => {
111-
render(
112-
<ActivityExecutionErrorReportModal
113-
onDiscard={jest.fn()}
114-
report={<p>Error details</p>}
115-
downloadButtonValue="Download"
116-
closeButtonValue="Close"
117-
fetchErrorReport={async () => "Error details"}
118-
/>,
119-
);
120-
expect(screen.getByRole("dialog", { name: "Activity execution error report" })).toBeInTheDocument();
121-
});
110+
it.each([undefined, ""])(
111+
"uses an english fallback name if neither title nor aria attributes are given (aria-label: %p)",
112+
(ariaLabel) => {
113+
render(
114+
<ActivityExecutionErrorReportModal
115+
aria-label={ariaLabel}
116+
onDiscard={jest.fn()}
117+
report={<p>Error details</p>}
118+
downloadButtonValue="Download"
119+
closeButtonValue="Close"
120+
fetchErrorReport={async () => "Error details"}
121+
/>,
122+
);
123+
expect(screen.getByRole("dialog", { name: "Activity execution error report" })).toBeInTheDocument();
124+
},
125+
);
122126
});

‎src/components/Dialog/SimpleDialog.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ export const SimpleDialog = ({
130130
<IconButton
131131
name={displayFullscreen ? "toggler-minimize" : "toggler-maximize"}
132132
text={togglerText}
133+
tooltipAsTitle
133134
aria-label={togglerText}
134135
onClick={() => setDisplayFullscreen(!displayFullscreen)}
135136
/>

‎src/components/Dialog/tests/SimpleDialog.test.tsx‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,15 @@ describe("SimpleDialog", () => {
224224
fireEvent.click(toggler);
225225
expect(toggler).toHaveAccessibleName("Exit full screen");
226226
});
227+
it("should keep the toggler button itself focusable and show its text as title", () => {
228+
const { toggler } = renderDialog({ showFullScreenToggler: true });
229+
expect(toggler).not.toHaveAttribute("tabindex", "-1");
230+
expect(toggler).toHaveAttribute("title", "Show in full screen");
231+
expect(toggler.querySelector("[tabindex]")).toBeNull();
232+
233+
toggler.focus();
234+
expect(toggler).toHaveFocus();
235+
});
227236
it("should use custom toggler texts if given", () => {
228237
const { toggler } = renderDialog({
229238
showFullScreenToggler: true,

0 commit comments

Comments
 (0)