Fix current tag text not committed when changing note via shortcut key (#2441)
This commit is contained in:
parent
5774e5d4af
commit
146bed12d9
@ -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 Absolute from "../components/Absolute.svelte";
|
||||||
import Badge from "../components/Badge.svelte";
|
import Badge from "../components/Badge.svelte";
|
||||||
import { TagEditor } from "../tag-editor";
|
import { TagEditor } from "../tag-editor";
|
||||||
|
import { commitTagEdits } from "../tag-editor/TagInput.svelte";
|
||||||
import { ChangeTimer } from "./change-timer";
|
import { ChangeTimer } from "./change-timer";
|
||||||
import { clearableArray } from "./destroyable";
|
import { clearableArray } from "./destroyable";
|
||||||
import DuplicateLink from "./DuplicateLink.svelte";
|
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 */
|
/* this will always be a key save */
|
||||||
fieldSave.fireImmediately();
|
fieldSave.fireImmediately();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function saveNow(): void {
|
||||||
|
commitTagEdits();
|
||||||
|
saveFieldNow();
|
||||||
|
}
|
||||||
|
|
||||||
export function saveOnPageHide() {
|
export function saveOnPageHide() {
|
||||||
if (document.visibilityState === "hidden") {
|
if (document.visibilityState === "hidden") {
|
||||||
// will fire on session close and minimize
|
// 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,
|
setTagsCollapsed,
|
||||||
setBackgrounds,
|
setBackgrounds,
|
||||||
setClozeHint,
|
setClozeHint,
|
||||||
saveNow: saveFieldNow,
|
saveNow,
|
||||||
focusIfField,
|
focusIfField,
|
||||||
getNoteId,
|
getNoteId,
|
||||||
setNoteId,
|
setNoteId,
|
||||||
|
@ -2,12 +2,21 @@
|
|||||||
Copyright: Ankitects Pty Ltd and contributors
|
Copyright: Ankitects Pty Ltd and contributors
|
||||||
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
-->
|
-->
|
||||||
<script lang="ts">
|
<script context="module" lang="ts">
|
||||||
import { createEventDispatcher, getContext, onMount, tick } from "svelte";
|
let current: HTMLInputElement | null = null;
|
||||||
|
|
||||||
|
export function commitTagEdits(): void {
|
||||||
|
current?.blur();
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script lang="ts">
|
||||||
import { tagActionsShortcutsKey } from "@tslib/context-keys";
|
import { tagActionsShortcutsKey } from "@tslib/context-keys";
|
||||||
import { isArrowLeft, isArrowRight } from "@tslib/keys";
|
import { isArrowLeft, isArrowRight } from "@tslib/keys";
|
||||||
import { registerShortcut } from "@tslib/shortcuts";
|
import { registerShortcut } from "@tslib/shortcuts";
|
||||||
|
import { createEventDispatcher, getContext, onMount, tick } from "svelte";
|
||||||
|
import type { ActionReturn } from "svelte/action";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
delimChar,
|
delimChar,
|
||||||
normalizeTagname,
|
normalizeTagname,
|
||||||
@ -242,6 +251,17 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||||||
registerShortcut(onSelectAll, selectAllShortcut, { target: input });
|
registerShortcut(onSelectAll, selectAllShortcut, { target: input });
|
||||||
input.focus();
|
input.focus();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function updateCurrent(input: HTMLInputElement): ActionReturn {
|
||||||
|
current = input;
|
||||||
|
return {
|
||||||
|
destroy(): void {
|
||||||
|
if (current === input) {
|
||||||
|
current = null;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<input
|
<input
|
||||||
@ -261,6 +281,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||||||
on:input={() => dispatch("taginput")}
|
on:input={() => dispatch("taginput")}
|
||||||
on:copy|preventDefault={onCopy}
|
on:copy|preventDefault={onCopy}
|
||||||
on:paste|preventDefault={onPaste}
|
on:paste|preventDefault={onPaste}
|
||||||
|
use:updateCurrent
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
|
Loading…
Reference in New Issue
Block a user