Skip to content

Commit 0b87f65

Browse files
Copilotimnasnainaec
andcommitted
Use Dialog TransitionProps.onExited to handle focus after dialog closes
Co-authored-by: imnasnainaec <[email protected]>
1 parent 4216b18 commit 0b87f65

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

src/components/Buttons/NoteButton.tsx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,6 @@ interface NoteButtonProps {
1919
export default function NoteButton(props: NoteButtonProps): ReactElement {
2020
const [noteOpen, setNoteOpen] = useState<boolean>(false);
2121

22-
const handleClose = (): void => {
23-
setNoteOpen(false);
24-
if (props.onClick) {
25-
props.onClick();
26-
}
27-
};
28-
2922
return (
3023
<>
3124
<IconButtonWithTooltip
@@ -53,7 +46,8 @@ export default function NoteButton(props: NoteButtonProps): ReactElement {
5346
open={noteOpen}
5447
text={props.noteText}
5548
titleId={"addWords.addNote"}
56-
close={handleClose}
49+
close={() => setNoteOpen(false)}
50+
onExited={props.onClick}
5751
updateText={props.updateNote ?? (() => {})}
5852
buttonIdCancel="note-edit-cancel"
5953
buttonIdClear="note-edit-clear"

src/components/Dialogs/EditTextDialog.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ interface EditTextDialogProps {
2424
text: string;
2525
titleId: string;
2626
close: () => void;
27+
onExited?: () => void;
2728
updateText: (newText: string) => void | Promise<void>;
2829
buttonIdCancel?: string;
2930
buttonIdClear?: string;
@@ -90,6 +91,7 @@ export default function EditTextDialog(
9091
<Dialog
9192
open={props.open}
9293
onClose={escapeClose}
94+
TransitionProps={{ onExited: props.onExited }}
9395
aria-labelledby="alert-dialog-title"
9496
aria-describedby="alert-dialog-description"
9597
>

0 commit comments

Comments
 (0)