Skip to content

Commit 7d059ea

Browse files
committed
Remove dulicated functionality and add a label to the button
1 parent 965caf8 commit 7d059ea

3 files changed

Lines changed: 12 additions & 10 deletions

File tree

‎src/cmem/ActivityControl/ActivityExecutionErrorReportModal.tsx‎

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
import React, { useState } from "react";
1+
import React from "react";
22

33
import Button from "../../components/Button/Button";
44
import { ModalProps } from "../../components/Dialog/Modal";
55
import SimpleDialog from "../../components/Dialog/SimpleDialog";
6-
import IconButton from "../../components/Icon/IconButton";
76
import HtmlContentBlock from "../../components/Typography/HtmlContentBlock";
87

98
interface ActivityExecutionErrorReportModalProps extends Pick<ModalProps, "aria-label" | "aria-labelledby"> {
@@ -32,7 +31,6 @@ export const ActivityExecutionErrorReportModal = ({
3231
closeButtonValue,
3332
fetchErrorReport,
3433
}: ActivityExecutionErrorReportModalProps) => {
35-
const [displayFullscreen, setDisplayFullscreen] = useState<boolean>(false);
3634
const fileName =
3735
"Activity execution report from " +
3836
new Date().toISOString().replace(/T/, " ").replace(/:/g, "-").substr(0, 19) +
@@ -57,14 +55,9 @@ export const ActivityExecutionErrorReportModal = ({
5755
aria-label={ariaLabel}
5856
aria-labelledby={ariaLabelledby}
5957
isOpen={true}
60-
size={displayFullscreen ? "fullscreen" : "large"}
58+
size="large"
59+
showFullScreenToggler
6160
onClose={onDiscard}
62-
headerOptions={
63-
<IconButton
64-
name={displayFullscreen ? "toggler-minimize" : "toggler-maximize"}
65-
onClick={() => setDisplayFullscreen(!displayFullscreen)}
66-
/>
67-
}
6861
actions={[
6962
<Button data-test-id={"error-report-download-btn"} affirmative onClick={handleDownload} key="download">
7063
{downloadButtonValue}

‎src/components/Dialog/SimpleDialog.tsx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ export const SimpleDialog = ({
8080
const dialogUniqueId = React.useId().replace(/[^a-zA-Z0-9_-]/g, "");
8181
const [displayFullscreen, setDisplayFullscreen] = React.useState<boolean>(startInFullScreenMode);
8282
const showToggler = startInFullScreenMode || showFullScreenToggler;
83+
const togglerText = displayFullscreen ? "Exit full screen" : "Show in full screen";
8384
const intentClassName = intent ? `${eccgui}-intent--${intent}` : "";
8485
const wrapperDivProps = {
8586
...modalPreventEvents,
@@ -116,6 +117,7 @@ export const SimpleDialog = ({
116117
{showToggler && (
117118
<IconButton
118119
name={displayFullscreen ? "toggler-minimize" : "toggler-maximize"}
120+
text={togglerText}
119121
onClick={() => setDisplayFullscreen(!displayFullscreen)}
120122
/>
121123
)}

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,13 @@ describe("SimpleDialog", () => {
217217
fireEvent.click(toggler);
218218
expect(dialog).toHaveClass(`${dialogWrapper}--small`);
219219
});
220+
it("should give the toggler an accessible name that reflects its state", () => {
221+
const { toggler } = renderDialog({ showFullScreenToggler: true });
222+
expect(toggler).toHaveAccessibleName("Show in full screen");
223+
224+
fireEvent.click(toggler);
225+
expect(toggler).toHaveAccessibleName("Exit full screen");
226+
});
220227
it("should start in full screen mode and enable the toggler", () => {
221228
const { dialog, toggler } = renderDialog({ startInFullScreenMode: true, size: "small" });
222229
expect(dialog).toHaveClass(`${dialogWrapper}--fullscreen`);

0 commit comments

Comments
 (0)