Skip to content

Commit

Permalink
Convert modal to dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
yoonieaj committed Oct 3, 2024
1 parent d6386d3 commit aeef171
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 40 deletions.
67 changes: 30 additions & 37 deletions demo/src/MemoryModelsUserInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ import {
Stack,
Modal,
Paper,
Dialog,
DialogActions,
DialogContent,
} from "@mui/material";
import DownloadJSONButton from "./DownloadJSONButton";
import MemoryModelsMenu from "./MemoryModelsMenu";
Expand Down Expand Up @@ -79,46 +82,36 @@ function MemoryModelsFileInput(props: MemoryModelsFileInputPropTypes) {
<Button onClick={handleOpen} sx={{ textTransform: "none" }}>
Upload JSON File
</Button>
<Modal
<Dialog
open={open}
onClose={handleClose}
data-testid="file-input-modal"
data-testid="file-input-dialog"
>
<Paper
sx={{
position: "absolute",
top: "40%",
left: "20%",
width: "50%",
padding: 2,
}}
>
<div>
<Input
type="file"
onChange={onChange}
inputProps={{
accept: "application/JSON",
"data-testid": "file-input",
}}
disableUnderline={true}
sx={{ alignSelf: "center" }}
/>
</div>
<div>
<Button
data-testid="file-input-reapply-button"
variant="contained"
color="primary"
disabled={!uploadedFileString}
onClick={onLoadButtonClick}
sx={{ textTransform: "none" }}
>
Load file data
</Button>
</div>
</Paper>
</Modal>
<DialogContent>
<Input
type="file"
onChange={onChange}
inputProps={{
accept: "application/JSON",
"data-testid": "file-input",
}}
disableUnderline={true}
sx={{ alignSelf: "center" }}
/>
</DialogContent>
<DialogActions>
<Button
data-testid="file-input-reapply-button"
variant="contained"
color="primary"
disabled={!uploadedFileString}
onClick={onLoadButtonClick}
sx={{ textTransform: "none" }}
>
Load file data
</Button>
</DialogActions>
</Dialog>
</div>
);
}
Expand Down
6 changes: 3 additions & 3 deletions demo/src/__tests__/MemoryModelsUserInput.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@ describe("MemoryModelsUserInput", () => {
jest.restoreAllMocks();
});

it("does not render the modal when the page first loads", () => {
const modal = screen.queryByTestId("file-input-modal");
expect(modal).toBeNull();
it("does not render the dialog when the page first loads", () => {
const dialog = screen.queryByTestId("file-input-dialog");
expect(dialog).toBeNull();

const input: HTMLInputElement = screen.queryByTestId("file-input");
expect(input).toBeNull();
Expand Down

0 comments on commit aeef171

Please sign in to comment.