Skip to content

Build your personal knowledge base with Trilium Notes

refactor(note_type_chooser): inline the single-caller focus helper

Elian Doran1c9e146fe5f4
diff --git a/apps/client/src/widgets/dialogs/note_type_chooser.tsx b/apps/client/src/widgets/dialogs/note_type_chooser.tsx
index 1f269299a3..7fc12ea2e0 100644
--- a/apps/client/src/widgets/dialogs/note_type_chooser.tsx
+++ b/apps/client/src/widgets/dialogs/note_type_chooser.tsx
@@ -90,9 +90,11 @@ export default function NoteTypeChooserDialogComponent() {
}, [ shown, noteTypes.length ]);
function tryFocusFirstNoteType() {
- if (!userMovedFocus.current) {
- focusFirstNoteType(modalRef.current);
+ if (userMovedFocus.current) {
+ return;
}
+
+ modalRef.current?.querySelector<HTMLElement>(".dropdownWrapper .dropdown-item:not(.disabled)")?.focus();
}
function onNoteTypeSelected(value: string) {
@@ -160,7 +162,3 @@ export default function NoteTypeChooserDialogComponent() {
</Modal>
);
}
-
-function focusFirstNoteType(modal: HTMLDivElement | null) {
- modal?.querySelector<HTMLElement>(".dropdownWrapper .dropdown-item:not(.disabled)")?.focus();
-}