Skip to content

Commit e785420

Browse files
committed
added functionality of submitting dialog on pressing ‘enter’ across project
1 parent ff60a64 commit e785420

File tree

2 files changed

+21
-14
lines changed

2 files changed

+21
-14
lines changed

src/features/TestAString.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,13 @@ const TestAString = (props: TestAStringProps) => {
318318

319319
return (
320320
<>
321-
<Dialog open={props.isTestAStringDialogOpen} onClose={handleClose}>
321+
<Dialog
322+
open={props.isTestAStringDialogOpen}
323+
onClose={handleClose}
324+
onKeyUp={(e) => {
325+
if (e?.key === "Enter") handleSubmit();
326+
}}
327+
>
322328
<DialogTitle>Test a string</DialogTitle>
323329
<DialogContent>
324330
<DialogContentText>

src/features/components/playground/TopBar.tsx

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,16 @@ export const TopBar = (props: TopBarProps) => {
428428
props.handleSelect(null);
429429
};
430430

431+
const handleTopbarDialogSubmit = () => {
432+
dialogType === 0
433+
? handleEditStateName()
434+
: dialogType === 1
435+
? handleEditTransitionLabel()
436+
: dialogType === 2
437+
? handleRemoveTransitions()
438+
: handleDeleteState();
439+
};
440+
431441
var returnTopBarAppearance = () => {
432442
let allowedActions: string[] = [];
433443

@@ -472,6 +482,9 @@ export const TopBar = (props: TopBarProps) => {
472482
id="topbarDialog"
473483
open={isTopbarDialogOpen}
474484
onClose={() => setIsTopbarDialogOpen(false)}
485+
onKeyUp={(e) => {
486+
if (e?.key === "Enter") handleTopbarDialogSubmit();
487+
}}
475488
>
476489
<DialogTitle id="topbarDialogTitle">
477490
{dialogType === 0
@@ -511,19 +524,7 @@ export const TopBar = (props: TopBarProps) => {
511524
)}
512525
<DialogActions id="topbarDialogActions">
513526
<Button onClick={() => setIsTopbarDialogOpen(false)}>Cancel</Button>
514-
<Button
515-
onClick={() => {
516-
dialogType === 0
517-
? handleEditStateName()
518-
: dialogType === 1
519-
? handleEditTransitionLabel()
520-
: dialogType === 2
521-
? handleRemoveTransitions()
522-
: handleDeleteState();
523-
}}
524-
>
525-
Ok
526-
</Button>
527+
<Button onClick={handleTopbarDialogSubmit}>Ok</Button>
527528
</DialogActions>
528529
</Dialog>
529530

0 commit comments

Comments
 (0)