Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
fix(collections/board): double entry on Enter + dismiss not working
Elian Doran1ae81abf0a46
diff --git a/apps/client/src/widgets/collections/board/index.tsx b/apps/client/src/widgets/collections/board/index.tsxindex e11beb2032..e868e5d309 100644--- a/apps/client/src/widgets/collections/board/index.tsx+++ b/apps/client/src/widgets/collections/board/index.tsx@@ -228,6 +228,7 @@ export function TitleEditor({ currentValue, placeholder, save, dismiss, multilin}) {const inputRef = useRef<any>(null);const dismissOnNextRefreshRef = useRef(false);+ const shouldSave = useRef(false);useEffect(() => {inputRef.current?.focus();@@ -251,20 +252,14 @@ export function TitleEditor({ currentValue, placeholder, save, dismiss, multilinautoComplete="trilium-title-entry" // forces the auto-fill off better than the "off" value.rows={multiline ? 4 : undefined}onKeyDown={(e: JSX.TargetedKeyboardEvent<HTMLInputElement | HTMLTextAreaElement>) => {- if (e.key === "Enter") {- const newValue = e.currentTarget?.value;- if (newValue.trim() && (newValue !== currentValue || isNewItem)) {- save(newValue);- dismissOnNextRefreshRef.current = true;- }- }-- if (e.key === "Escape") {- dismiss();+ if (e.key === "Enter" || e.key === "Escape") {+ e.preventDefault();+ shouldSave.current = (e.key === "Enter");+ e.currentTarget.blur();}}}onBlur={(newValue) => {- if (newValue.trim() && (newValue !== currentValue || isNewItem)) {+ if (shouldSave.current && newValue.trim() && (newValue !== currentValue || isNewItem)) {save(newValue);dismissOnNextRefreshRef.current = true;} else {