From d277779d337adbc104b82f662a8d9d0fede8085c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 21 Nov 2025 19:03:55 +0000 Subject: [PATCH 01/12] Initial plan From 4216b18cf31b05120e151cbbc42a8ff1639fd9db Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 21 Nov 2025 19:14:56 +0000 Subject: [PATCH 02/12] Return focus to gloss field after note button interaction Co-authored-by: imnasnainaec <6411521+imnasnainaec@users.noreply.github.com> --- src/components/Buttons/NoteButton.tsx | 10 +++++- .../DataEntryTable/NewEntry/index.tsx | 1 + .../NewEntry/tests/index.test.tsx | 34 +++++++++++++++++++ 3 files changed, 44 insertions(+), 1 deletion(-) diff --git a/src/components/Buttons/NoteButton.tsx b/src/components/Buttons/NoteButton.tsx index 1b8bc4948c..3db622bb4e 100644 --- a/src/components/Buttons/NoteButton.tsx +++ b/src/components/Buttons/NoteButton.tsx @@ -11,6 +11,7 @@ interface NoteButtonProps { /** If `noteText` is empty and `updateNote` defined, * the button will have default add-note hover text. */ noteText: string; + onClick?: () => void; updateNote?: (newText: string) => void | Promise; } @@ -18,6 +19,13 @@ interface NoteButtonProps { export default function NoteButton(props: NoteButtonProps): ReactElement { const [noteOpen, setNoteOpen] = useState(false); + const handleClose = (): void => { + setNoteOpen(false); + if (props.onClick) { + props.onClick(); + } + }; + return ( <> setNoteOpen(false)} + close={handleClose} updateText={props.updateNote ?? (() => {})} buttonIdCancel="note-edit-cancel" buttonIdClear="note-edit-clear" diff --git a/src/components/DataEntry/DataEntryTable/NewEntry/index.tsx b/src/components/DataEntry/DataEntryTable/NewEntry/index.tsx index bb79f5dc5a..4dff915bd8 100644 --- a/src/components/DataEntry/DataEntryTable/NewEntry/index.tsx +++ b/src/components/DataEntry/DataEntryTable/NewEntry/index.tsx @@ -277,6 +277,7 @@ export default function NewEntry(props: NewEntryProps): ReactElement { focus(FocusTarget.Gloss)} updateNote={setNewNote} /> )} diff --git a/src/components/DataEntry/DataEntryTable/NewEntry/tests/index.test.tsx b/src/components/DataEntry/DataEntryTable/NewEntry/tests/index.test.tsx index 5810af6106..111521a8e6 100644 --- a/src/components/DataEntry/DataEntryTable/NewEntry/tests/index.test.tsx +++ b/src/components/DataEntry/DataEntryTable/NewEntry/tests/index.test.tsx @@ -1,3 +1,4 @@ +import "@testing-library/jest-dom"; import { act, fireEvent, render, screen } from "@testing-library/react"; import userEvent from "@testing-library/user-event"; import { createRef } from "react"; @@ -7,6 +8,7 @@ import configureMockStore from "redux-mock-store"; import NewEntry, { NewEntryId, } from "components/DataEntry/DataEntryTable/NewEntry"; +import { focusInput } from "components/DataEntry/utilities"; import { newWritingSystem } from "types/writingSystem"; jest.mock("components/DataEntry/utilities.ts", () => ({ @@ -173,4 +175,36 @@ describe("NewEntry", () => { expect(mockAddNewEntry).toHaveBeenCalledTimes(1); expect(mockResetNewEntry).toHaveBeenCalledTimes(1); }); + + it("returns focus to gloss after closing note dialog", async () => { + (focusInput as jest.Mock).mockClear(); + await renderNewEntry("", "", ""); + + // Click the note button to open the dialog + const noteButton = screen.getByTestId(NewEntryId.ButtonNote); + await userEvent.click(noteButton); + + // Click cancel to close the dialog + const cancelButton = screen.getByTestId("note-edit-cancel"); + await userEvent.click(cancelButton); + + // Verify that focusInput was called (which should focus the gloss field) + expect(focusInput).toHaveBeenCalled(); + }); + + it("returns focus to gloss after confirming note", async () => { + (focusInput as jest.Mock).mockClear(); + await renderNewEntry("", "", ""); + + // Click the note button to open the dialog + const noteButton = screen.getByTestId(NewEntryId.ButtonNote); + await userEvent.click(noteButton); + + // Click confirm to close the dialog + const confirmButton = screen.getByTestId("note-edit-confirm"); + await userEvent.click(confirmButton); + + // Verify that focusInput was called (which should focus the gloss field) + expect(focusInput).toHaveBeenCalled(); + }); }); From 0b87f6587c3a417b44bc518f4bb6581872afaacd Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 21 Nov 2025 20:02:56 +0000 Subject: [PATCH 03/12] Use Dialog TransitionProps.onExited to handle focus after dialog closes Co-authored-by: imnasnainaec <6411521+imnasnainaec@users.noreply.github.com> --- src/components/Buttons/NoteButton.tsx | 10 ++-------- src/components/Dialogs/EditTextDialog.tsx | 2 ++ 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/components/Buttons/NoteButton.tsx b/src/components/Buttons/NoteButton.tsx index 3db622bb4e..e859e4faae 100644 --- a/src/components/Buttons/NoteButton.tsx +++ b/src/components/Buttons/NoteButton.tsx @@ -19,13 +19,6 @@ interface NoteButtonProps { export default function NoteButton(props: NoteButtonProps): ReactElement { const [noteOpen, setNoteOpen] = useState(false); - const handleClose = (): void => { - setNoteOpen(false); - if (props.onClick) { - props.onClick(); - } - }; - return ( <> setNoteOpen(false)} + onExited={props.onClick} updateText={props.updateNote ?? (() => {})} buttonIdCancel="note-edit-cancel" buttonIdClear="note-edit-clear" diff --git a/src/components/Dialogs/EditTextDialog.tsx b/src/components/Dialogs/EditTextDialog.tsx index 5ca977ed1b..1abfa196c9 100644 --- a/src/components/Dialogs/EditTextDialog.tsx +++ b/src/components/Dialogs/EditTextDialog.tsx @@ -24,6 +24,7 @@ interface EditTextDialogProps { text: string; titleId: string; close: () => void; + onExited?: () => void; updateText: (newText: string) => void | Promise; buttonIdCancel?: string; buttonIdClear?: string; @@ -90,6 +91,7 @@ export default function EditTextDialog( From 71ddd9906e3b4fa601fbf2737ebe985b3d5b7017 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 21 Nov 2025 20:23:46 +0000 Subject: [PATCH 04/12] Add disableRestoreFocus to Dialog to prevent focus flash on button Co-authored-by: imnasnainaec <6411521+imnasnainaec@users.noreply.github.com> --- src/components/Dialogs/EditTextDialog.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/Dialogs/EditTextDialog.tsx b/src/components/Dialogs/EditTextDialog.tsx index 1abfa196c9..0731ea7ce5 100644 --- a/src/components/Dialogs/EditTextDialog.tsx +++ b/src/components/Dialogs/EditTextDialog.tsx @@ -89,6 +89,7 @@ export default function EditTextDialog( return ( Date: Fri, 21 Nov 2025 20:25:42 +0000 Subject: [PATCH 05/12] Add comment explaining disableRestoreFocus usage Co-authored-by: imnasnainaec <6411521+imnasnainaec@users.noreply.github.com> --- src/components/Dialogs/EditTextDialog.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Dialogs/EditTextDialog.tsx b/src/components/Dialogs/EditTextDialog.tsx index 0731ea7ce5..d5349f3252 100644 --- a/src/components/Dialogs/EditTextDialog.tsx +++ b/src/components/Dialogs/EditTextDialog.tsx @@ -89,7 +89,7 @@ export default function EditTextDialog( return ( Date: Fri, 21 Nov 2025 15:38:45 -0500 Subject: [PATCH 06/12] Tidy --- src/components/Buttons/NoteButton.tsx | 4 ++-- src/components/DataEntry/DataEntryTable/NewEntry/index.tsx | 2 +- src/components/Dialogs/EditTextDialog.tsx | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/components/Buttons/NoteButton.tsx b/src/components/Buttons/NoteButton.tsx index e859e4faae..6c9eb30e1b 100644 --- a/src/components/Buttons/NoteButton.tsx +++ b/src/components/Buttons/NoteButton.tsx @@ -11,7 +11,7 @@ interface NoteButtonProps { /** If `noteText` is empty and `updateNote` defined, * the button will have default add-note hover text. */ noteText: string; - onClick?: () => void; + onExited?: () => void; updateNote?: (newText: string) => void | Promise; } @@ -47,7 +47,7 @@ export default function NoteButton(props: NoteButtonProps): ReactElement { text={props.noteText} titleId={"addWords.addNote"} close={() => setNoteOpen(false)} - onExited={props.onClick} + onExited={props.onExited} updateText={props.updateNote ?? (() => {})} buttonIdCancel="note-edit-cancel" buttonIdClear="note-edit-clear" diff --git a/src/components/DataEntry/DataEntryTable/NewEntry/index.tsx b/src/components/DataEntry/DataEntryTable/NewEntry/index.tsx index 4dff915bd8..fd650353a9 100644 --- a/src/components/DataEntry/DataEntryTable/NewEntry/index.tsx +++ b/src/components/DataEntry/DataEntryTable/NewEntry/index.tsx @@ -277,7 +277,7 @@ export default function NewEntry(props: NewEntryProps): ReactElement { focus(FocusTarget.Gloss)} + onExited={() => focus(FocusTarget.Gloss)} updateNote={setNewNote} /> )} diff --git a/src/components/Dialogs/EditTextDialog.tsx b/src/components/Dialogs/EditTextDialog.tsx index d5349f3252..d5e33089cb 100644 --- a/src/components/Dialogs/EditTextDialog.tsx +++ b/src/components/Dialogs/EditTextDialog.tsx @@ -89,10 +89,10 @@ export default function EditTextDialog( return ( From 45319b422ac35adca448865afbce9b659343107d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 21 Nov 2025 20:48:36 +0000 Subject: [PATCH 07/12] Always disable focus restore and add small delay to focus callback Co-authored-by: imnasnainaec <6411521+imnasnainaec@users.noreply.github.com> --- src/components/DataEntry/DataEntryTable/NewEntry/index.tsx | 2 +- src/components/Dialogs/EditTextDialog.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/DataEntry/DataEntryTable/NewEntry/index.tsx b/src/components/DataEntry/DataEntryTable/NewEntry/index.tsx index fd650353a9..de42de64ba 100644 --- a/src/components/DataEntry/DataEntryTable/NewEntry/index.tsx +++ b/src/components/DataEntry/DataEntryTable/NewEntry/index.tsx @@ -277,7 +277,7 @@ export default function NewEntry(props: NewEntryProps): ReactElement { focus(FocusTarget.Gloss)} + onExited={() => setTimeout(() => focus(FocusTarget.Gloss), 10)} updateNote={setNewNote} /> )} diff --git a/src/components/Dialogs/EditTextDialog.tsx b/src/components/Dialogs/EditTextDialog.tsx index d5e33089cb..d90cda9da7 100644 --- a/src/components/Dialogs/EditTextDialog.tsx +++ b/src/components/Dialogs/EditTextDialog.tsx @@ -89,7 +89,7 @@ export default function EditTextDialog( return ( Date: Fri, 21 Nov 2025 20:51:07 +0000 Subject: [PATCH 08/12] Extract focus delay to named constant and improve comment Co-authored-by: imnasnainaec <6411521+imnasnainaec@users.noreply.github.com> --- src/components/DataEntry/DataEntryTable/NewEntry/index.tsx | 7 ++++++- src/components/Dialogs/EditTextDialog.tsx | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/components/DataEntry/DataEntryTable/NewEntry/index.tsx b/src/components/DataEntry/DataEntryTable/NewEntry/index.tsx index de42de64ba..4660540f34 100644 --- a/src/components/DataEntry/DataEntryTable/NewEntry/index.tsx +++ b/src/components/DataEntry/DataEntryTable/NewEntry/index.tsx @@ -36,6 +36,9 @@ export enum FocusTarget { Vernacular, } +/** Delay in ms to ensure focus change happens after browser focus management completes */ +const FOCUS_DELAY_MS = 10; + interface NewEntryProps { analysisLang: WritingSystem; vernacularLang: WritingSystem; @@ -277,7 +280,9 @@ export default function NewEntry(props: NewEntryProps): ReactElement { setTimeout(() => focus(FocusTarget.Gloss), 10)} + onExited={() => + setTimeout(() => focus(FocusTarget.Gloss), FOCUS_DELAY_MS) + } updateNote={setNewNote} /> )} diff --git a/src/components/Dialogs/EditTextDialog.tsx b/src/components/Dialogs/EditTextDialog.tsx index d90cda9da7..a1cf964617 100644 --- a/src/components/Dialogs/EditTextDialog.tsx +++ b/src/components/Dialogs/EditTextDialog.tsx @@ -89,7 +89,7 @@ export default function EditTextDialog( return ( Date: Mon, 24 Nov 2025 13:04:03 +0000 Subject: [PATCH 09/12] Remove setTimeout delay and blur button on open to prevent focus restoration Co-authored-by: imnasnainaec <6411521+imnasnainaec@users.noreply.github.com> --- src/components/Buttons/NoteButton.tsx | 10 +++++++++- .../DataEntry/DataEntryTable/NewEntry/index.tsx | 7 +------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/components/Buttons/NoteButton.tsx b/src/components/Buttons/NoteButton.tsx index 6c9eb30e1b..67c314f480 100644 --- a/src/components/Buttons/NoteButton.tsx +++ b/src/components/Buttons/NoteButton.tsx @@ -19,6 +19,14 @@ interface NoteButtonProps { export default function NoteButton(props: NoteButtonProps): ReactElement { const [noteOpen, setNoteOpen] = useState(false); + const handleOpen = (): void => { + setNoteOpen(true); + // Blur the button to prevent it from receiving focus when dialog closes + if (document.activeElement instanceof HTMLElement) { + document.activeElement.blur(); + } + }; + return ( <> ) } - onClick={props.updateNote ? () => setNoteOpen(true) : undefined} + onClick={props.updateNote ? handleOpen : undefined} side="top" size="small" text={props.noteText || undefined} diff --git a/src/components/DataEntry/DataEntryTable/NewEntry/index.tsx b/src/components/DataEntry/DataEntryTable/NewEntry/index.tsx index 4660540f34..fd650353a9 100644 --- a/src/components/DataEntry/DataEntryTable/NewEntry/index.tsx +++ b/src/components/DataEntry/DataEntryTable/NewEntry/index.tsx @@ -36,9 +36,6 @@ export enum FocusTarget { Vernacular, } -/** Delay in ms to ensure focus change happens after browser focus management completes */ -const FOCUS_DELAY_MS = 10; - interface NewEntryProps { analysisLang: WritingSystem; vernacularLang: WritingSystem; @@ -280,9 +277,7 @@ export default function NewEntry(props: NewEntryProps): ReactElement { - setTimeout(() => focus(FocusTarget.Gloss), FOCUS_DELAY_MS) - } + onExited={() => focus(FocusTarget.Gloss)} updateNote={setNewNote} /> )} From e8ea1ad9b6320188a1c5ada83315819bae87c94c Mon Sep 17 00:00:00 2001 From: Danny Rorabaugh Date: Mon, 24 Nov 2025 08:46:38 -0500 Subject: [PATCH 10/12] Clean up --- src/components/Buttons/NoteButton.tsx | 10 +++-- .../NewEntry/tests/index.test.tsx | 43 ++++++++----------- src/components/Dialogs/EditTextDialog.tsx | 1 - 3 files changed, 26 insertions(+), 28 deletions(-) diff --git a/src/components/Buttons/NoteButton.tsx b/src/components/Buttons/NoteButton.tsx index 67c314f480..74cffa7e9c 100644 --- a/src/components/Buttons/NoteButton.tsx +++ b/src/components/Buttons/NoteButton.tsx @@ -21,9 +21,13 @@ export default function NoteButton(props: NoteButtonProps): ReactElement { const handleOpen = (): void => { setNoteOpen(true); - // Blur the button to prevent it from receiving focus when dialog closes - if (document.activeElement instanceof HTMLElement) { - document.activeElement.blur(); + + if (props.onExited) { + // Allow custom focus handling after dialog closes + if (document.activeElement instanceof HTMLElement) { + // Blur the button to prevent it from receiving focus when dialog closes + document.activeElement.blur(); + } } }; diff --git a/src/components/DataEntry/DataEntryTable/NewEntry/tests/index.test.tsx b/src/components/DataEntry/DataEntryTable/NewEntry/tests/index.test.tsx index 111521a8e6..ad258a1b29 100644 --- a/src/components/DataEntry/DataEntryTable/NewEntry/tests/index.test.tsx +++ b/src/components/DataEntry/DataEntryTable/NewEntry/tests/index.test.tsx @@ -8,18 +8,18 @@ import configureMockStore from "redux-mock-store"; import NewEntry, { NewEntryId, } from "components/DataEntry/DataEntryTable/NewEntry"; -import { focusInput } from "components/DataEntry/utilities"; import { newWritingSystem } from "types/writingSystem"; jest.mock("components/DataEntry/utilities.ts", () => ({ ...jest.requireActual("components/DataEntry/utilities.ts"), - focusInput: jest.fn(), + focusInput: () => mockFocusInput(), })); jest.mock("components/Pronunciations/PronunciationsFrontend", () => jest.fn()); const mockAddNewAudio = jest.fn(); const mockAddNewEntry = jest.fn(); const mockDelNewAudio = jest.fn(); +const mockFocusInput = jest.fn(); const mockSetNewGloss = jest.fn(); const mockSetNewNote = jest.fn(); const mockSetNewVern = jest.fn(); @@ -81,7 +81,7 @@ const fireEnterOnActiveElement = async (): Promise => { }; beforeEach(() => { - jest.resetAllMocks(); + jest.clearAllMocks(); }); afterEach(() => { @@ -177,34 +177,29 @@ describe("NewEntry", () => { }); it("returns focus to gloss after closing note dialog", async () => { - (focusInput as jest.Mock).mockClear(); - await renderNewEntry("", "", ""); + await renderNewEntry(); + mockFocusInput.mockClear(); // Click the note button to open the dialog - const noteButton = screen.getByTestId(NewEntryId.ButtonNote); - await userEvent.click(noteButton); - - // Click cancel to close the dialog - const cancelButton = screen.getByTestId("note-edit-cancel"); - await userEvent.click(cancelButton); + await userEvent.click(screen.getByTestId(NewEntryId.ButtonNote)); + expect(mockFocusInput).not.toHaveBeenCalled(); - // Verify that focusInput was called (which should focus the gloss field) - expect(focusInput).toHaveBeenCalled(); + // Cancel and verify that focusInput was called + await userEvent.click(screen.getByText(new RegExp("cancel"))); + expect(mockFocusInput).toHaveBeenCalled(); }); it("returns focus to gloss after confirming note", async () => { - (focusInput as jest.Mock).mockClear(); - await renderNewEntry("", "", ""); - - // Click the note button to open the dialog - const noteButton = screen.getByTestId(NewEntryId.ButtonNote); - await userEvent.click(noteButton); + await renderNewEntry(); + mockFocusInput.mockClear(); - // Click confirm to close the dialog - const confirmButton = screen.getByTestId("note-edit-confirm"); - await userEvent.click(confirmButton); + // Click the note button to open the dialog and type a note + await userEvent.click(screen.getByTestId(NewEntryId.ButtonNote)); + await userEvent.type(document.activeElement!, "note text"); + expect(mockFocusInput).not.toHaveBeenCalled(); - // Verify that focusInput was called (which should focus the gloss field) - expect(focusInput).toHaveBeenCalled(); + // Confirm and verify that focusInput was called + await userEvent.click(screen.getByText(new RegExp("confirm"))); + expect(mockFocusInput).toHaveBeenCalled(); }); }); diff --git a/src/components/Dialogs/EditTextDialog.tsx b/src/components/Dialogs/EditTextDialog.tsx index a1cf964617..4c59bd1703 100644 --- a/src/components/Dialogs/EditTextDialog.tsx +++ b/src/components/Dialogs/EditTextDialog.tsx @@ -89,7 +89,6 @@ export default function EditTextDialog( return ( Date: Mon, 24 Nov 2025 13:53:43 +0000 Subject: [PATCH 11/12] Fix test timing issues with waitFor for onExited callback Co-authored-by: imnasnainaec <6411521+imnasnainaec@users.noreply.github.com> --- .../NewEntry/tests/index.test.tsx | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/components/DataEntry/DataEntryTable/NewEntry/tests/index.test.tsx b/src/components/DataEntry/DataEntryTable/NewEntry/tests/index.test.tsx index ad258a1b29..4a5c224078 100644 --- a/src/components/DataEntry/DataEntryTable/NewEntry/tests/index.test.tsx +++ b/src/components/DataEntry/DataEntryTable/NewEntry/tests/index.test.tsx @@ -1,5 +1,11 @@ import "@testing-library/jest-dom"; -import { act, fireEvent, render, screen } from "@testing-library/react"; +import { + act, + fireEvent, + render, + screen, + waitFor, +} from "@testing-library/react"; import userEvent from "@testing-library/user-event"; import { createRef } from "react"; import { Provider } from "react-redux"; @@ -184,9 +190,9 @@ describe("NewEntry", () => { await userEvent.click(screen.getByTestId(NewEntryId.ButtonNote)); expect(mockFocusInput).not.toHaveBeenCalled(); - // Cancel and verify that focusInput was called - await userEvent.click(screen.getByText(new RegExp("cancel"))); - expect(mockFocusInput).toHaveBeenCalled(); + // Cancel and verify that focusInput was called after transition completes + await userEvent.click(screen.getByText(new RegExp("cancel", "i"))); + await waitFor(() => expect(mockFocusInput).toHaveBeenCalled()); }); it("returns focus to gloss after confirming note", async () => { @@ -198,8 +204,8 @@ describe("NewEntry", () => { await userEvent.type(document.activeElement!, "note text"); expect(mockFocusInput).not.toHaveBeenCalled(); - // Confirm and verify that focusInput was called - await userEvent.click(screen.getByText(new RegExp("confirm"))); - expect(mockFocusInput).toHaveBeenCalled(); + // Confirm and verify that focusInput was called after transition completes + await userEvent.click(screen.getByText(new RegExp("confirm", "i"))); + await waitFor(() => expect(mockFocusInput).toHaveBeenCalled()); }); }); From 65c093c450fe373da01f2d2200c43fbc3a703ba0 Mon Sep 17 00:00:00 2001 From: Danny Rorabaugh Date: Mon, 24 Nov 2025 08:59:02 -0500 Subject: [PATCH 12/12] Remove unnecessary flag --- .../DataEntry/DataEntryTable/NewEntry/tests/index.test.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/DataEntry/DataEntryTable/NewEntry/tests/index.test.tsx b/src/components/DataEntry/DataEntryTable/NewEntry/tests/index.test.tsx index 4a5c224078..12953c14db 100644 --- a/src/components/DataEntry/DataEntryTable/NewEntry/tests/index.test.tsx +++ b/src/components/DataEntry/DataEntryTable/NewEntry/tests/index.test.tsx @@ -191,7 +191,7 @@ describe("NewEntry", () => { expect(mockFocusInput).not.toHaveBeenCalled(); // Cancel and verify that focusInput was called after transition completes - await userEvent.click(screen.getByText(new RegExp("cancel", "i"))); + await userEvent.click(screen.getByText(new RegExp("cancel"))); await waitFor(() => expect(mockFocusInput).toHaveBeenCalled()); }); @@ -205,7 +205,7 @@ describe("NewEntry", () => { expect(mockFocusInput).not.toHaveBeenCalled(); // Confirm and verify that focusInput was called after transition completes - await userEvent.click(screen.getByText(new RegExp("confirm", "i"))); + await userEvent.click(screen.getByText(new RegExp("confirm"))); await waitFor(() => expect(mockFocusInput).toHaveBeenCalled()); }); });