Skip to content

Commit ffb4dab

Browse files
committed
fixed bug where transition label wasn't being set when clicked somewhere inside topbarDialog in Playground
1 parent 0e82095 commit ffb4dab

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

src/features/Playground.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,19 @@ const Playground = (props: PlaygroundProps) => {
6262
<div
6363
className="canvasStyle"
6464
id="canvas"
65-
onClick={() => props.handleSelect(null)}
65+
onClick={(event) => {
66+
console.log("canvas clicked", event);
67+
// reset selected state if clicked outside topbarDialog
68+
if (
69+
!(
70+
(event.target as any)?.id?.includes("topbarDialog") ||
71+
(event.target as any)?.nextElementSibling?.id?.includes(
72+
"topbarDialog"
73+
)
74+
)
75+
)
76+
props.handleSelect(null);
77+
}}
6678
>
6779
<div
6880
id="statesContainer"

src/features/components/playground/TopBar.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -464,16 +464,19 @@ export const TopBar = (props: TopBarProps) => {
464464
return (
465465
<>
466466
<Dialog
467+
id="topbarDialog"
467468
open={isTopbarDialogOpen}
468469
onClose={() => setIsTopbarDialogOpen(false)}
469470
>
470-
<DialogTitle>
471+
<DialogTitle id="topbarDialogTitle">
471472
{dialogType
472473
? "Enter new Transition label(s)"
473474
: "Enter New State Name"}
474475
</DialogTitle>
475-
<DialogContent>
476-
<DialogContentText>{topbarDialogError}</DialogContentText>
476+
<DialogContent id="topbarDialogContent">
477+
<DialogContentText id="topbarDialogContentText">
478+
{topbarDialogError}
479+
</DialogContentText>
477480
<TextField
478481
autoFocus
479482
margin="dense"
@@ -482,6 +485,7 @@ export const TopBar = (props: TopBarProps) => {
482485
type="text"
483486
fullWidth
484487
variant="standard"
488+
autoComplete="off"
485489
value={topbarDialogValue}
486490
onChange={(e) =>
487491
setTopbarDialogValue(
@@ -494,7 +498,7 @@ export const TopBar = (props: TopBarProps) => {
494498
}
495499
/>
496500
</DialogContent>
497-
<DialogActions>
501+
<DialogActions id="topbarDialogActions">
498502
<Button onClick={() => setIsTopbarDialogOpen(false)}>Cancel</Button>
499503
<Button
500504
onClick={() => {

0 commit comments

Comments
 (0)