From 146bed12d9e14bee8620b61f367bd95f61b7d82e Mon Sep 17 00:00:00 2001 From: Hikaru Y Date: Thu, 16 Mar 2023 15:48:29 +0900 Subject: [PATCH] Fix current tag text not committed when changing note via shortcut key (#2441) --- ts/editor/NoteEditor.svelte | 10 ++++++++-- ts/tag-editor/TagInput.svelte | 25 +++++++++++++++++++++++-- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/ts/editor/NoteEditor.svelte b/ts/editor/NoteEditor.svelte index 21bb44e85..89bd89a50 100644 --- a/ts/editor/NoteEditor.svelte +++ b/ts/editor/NoteEditor.svelte @@ -48,6 +48,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html import Absolute from "../components/Absolute.svelte"; import Badge from "../components/Badge.svelte"; import { TagEditor } from "../tag-editor"; + import { commitTagEdits } from "../tag-editor/TagInput.svelte"; import { ChangeTimer } from "./change-timer"; import { clearableArray } from "./destroyable"; import DuplicateLink from "./DuplicateLink.svelte"; @@ -280,11 +281,16 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html ); } - export function saveFieldNow(): void { + function saveFieldNow(): void { /* this will always be a key save */ fieldSave.fireImmediately(); } + function saveNow(): void { + commitTagEdits(); + saveFieldNow(); + } + export function saveOnPageHide() { if (document.visibilityState === "hidden") { // will fire on session close and minimize @@ -352,7 +358,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html setTagsCollapsed, setBackgrounds, setClozeHint, - saveNow: saveFieldNow, + saveNow, focusIfField, getNoteId, setNoteId, diff --git a/ts/tag-editor/TagInput.svelte b/ts/tag-editor/TagInput.svelte index 23735a605..e90d44b22 100644 --- a/ts/tag-editor/TagInput.svelte +++ b/ts/tag-editor/TagInput.svelte @@ -2,12 +2,21 @@ Copyright: Ankitects Pty Ltd and contributors License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html --> - + + dispatch("taginput")} on:copy|preventDefault={onCopy} on:paste|preventDefault={onPaste} + use:updateCurrent />