Skip to content

Commit 3b9c290

Browse files
Copilotimnasnainaec
andcommitted
Extract focus delay to named constant and improve comment
Co-authored-by: imnasnainaec <6411521+imnasnainaec@users.noreply.github.com>
1 parent 45319b4 commit 3b9c290

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/components/DataEntry/DataEntryTable/NewEntry/index.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ export enum FocusTarget {
3636
Vernacular,
3737
}
3838

39+
/** Delay in ms to ensure focus change happens after browser focus management completes */
40+
const FOCUS_DELAY_MS = 10;
41+
3942
interface NewEntryProps {
4043
analysisLang: WritingSystem;
4144
vernacularLang: WritingSystem;
@@ -277,7 +280,9 @@ export default function NewEntry(props: NewEntryProps): ReactElement {
277280
<NoteButton
278281
buttonId={NewEntryId.ButtonNote}
279282
noteText={submitting ? "" : newNote}
280-
onExited={() => setTimeout(() => focus(FocusTarget.Gloss), 10)}
283+
onExited={() =>
284+
setTimeout(() => focus(FocusTarget.Gloss), FOCUS_DELAY_MS)
285+
}
281286
updateNote={setNewNote}
282287
/>
283288
)}

src/components/Dialogs/EditTextDialog.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export default function EditTextDialog(
8989

9090
return (
9191
<Dialog
92-
disableRestoreFocus // Prevent focus flash on triggering element when using onExited for custom focus handling
92+
disableRestoreFocus // Disable automatic focus restoration to allow custom focus handling
9393
open={props.open}
9494
onClose={escapeClose}
9595
slotProps={{ transition: { onExited: props.onExited } }}

0 commit comments

Comments
 (0)