refactor(react): allow binding multiple events at once

This commit is contained in:
Elian Doran
2025-08-21 13:17:28 +03:00
parent 51e8a80ca3
commit bea352855a
2 changed files with 16 additions and 11 deletions

View File

@@ -52,16 +52,10 @@ export default function NoteTitleWidget() {
// Manage focus.
const textBoxRef = useRef<HTMLInputElement>(null);
const isNewNote = useRef<boolean>();
useTriliumEventBeta("focusOnTitle", () => {
if (noteContext?.isActive() && textBoxRef.current) {
console.log(textBoxRef.current);
textBoxRef.current.focus();
}
});
useTriliumEventBeta("focusAndSelectTitle", ({ isNewNote: _isNewNote } ) => {
useTriliumEventBeta([ "focusOnTitle", "focusAndSelectTitle" ], (e) => {
if (noteContext?.isActive() && textBoxRef.current) {
textBoxRef.current.focus();
isNewNote.current = _isNewNote;
isNewNote.current = ("isNewNote" in e ? e.isNewNote : false);
}
});