From 1a8793797365449b7dca9f563ac003ce924839fa Mon Sep 17 00:00:00 2001 From: Henrik Giesel Date: Mon, 12 Sep 2022 11:22:22 +0200 Subject: [PATCH] Fix sticky field labels - Make editor toolbar+tag editor non sticky in editor (#2058) * Add back overflow:hidden to field descriptions * Add explaining comment * Put back overflow:hidden in FieldsEditor * Move inline padding from Fields component but EditorField+LabelContainer * Simplify editor design by making editor toolbar not sticky * Make tag editor in note editor non-sticky as well * Fix merge mess * The floating elements were portaled because I passed in undefined and they have a default argument - Fix unrelated to PR --- ts/components/WithFloating.svelte | 2 +- ts/editor/EditorField.svelte | 1 + ts/editor/FieldDescription.svelte | 5 + ts/editor/Fields.svelte | 13 +- ts/editor/FieldsEditor.svelte | 16 - ts/editor/LabelContainer.svelte | 11 +- ts/editor/NoteEditor.svelte | 330 +++++++++--------- ts/editor/editor-toolbar/EditorToolbar.svelte | 15 +- ts/sveltelib/portal.ts | 6 +- ts/tag-editor/TagEditor.svelte | 7 +- 10 files changed, 205 insertions(+), 201 deletions(-) delete mode 100644 ts/editor/FieldsEditor.svelte diff --git a/ts/components/WithFloating.svelte b/ts/components/WithFloating.svelte index 6de18e6bc..f0f6955a1 100644 --- a/ts/components/WithFloating.svelte +++ b/ts/components/WithFloating.svelte @@ -25,7 +25,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html import subscribeToUpdates from "../sveltelib/subscribe-updates"; import FloatingArrow from "./FloatingArrow.svelte"; - export let portalTarget: HTMLElement | undefined = undefined; + export let portalTarget: HTMLElement | null = null; export let placement: Placement | Placement[] | "auto" = "bottom"; export let offset = 5; diff --git a/ts/editor/EditorField.svelte b/ts/editor/EditorField.svelte index f87104cd4..fabf2286e 100644 --- a/ts/editor/EditorField.svelte +++ b/ts/editor/EditorField.svelte @@ -117,6 +117,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html diff --git a/ts/editor/FieldDescription.svelte b/ts/editor/FieldDescription.svelte index edf38b748..236a3b90c 100644 --- a/ts/editor/FieldDescription.svelte +++ b/ts/editor/FieldDescription.svelte @@ -43,5 +43,10 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html /* Stay a on single line */ white-space: nowrap; text-overflow: ellipsis; + + /* The field description is placed absolutely on top of the editor field */ + /* So we need to make sure it does not escape the editor field if the */ + /* description is too long */ + overflow: hidden; } diff --git a/ts/editor/Fields.svelte b/ts/editor/Fields.svelte index 29bdfa29e..ac8ee48d8 100644 --- a/ts/editor/Fields.svelte +++ b/ts/editor/Fields.svelte @@ -2,6 +2,10 @@ Copyright: Ankitects Pty Ltd and contributors License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html --> +
@@ -12,6 +16,13 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html grid-auto-rows: min-content; grid-gap: 6px; - padding: 0 3px 5px; + /* Add space after the last field and the start of the tag editor */ + padding-bottom: 5px; + + /* Move the scrollbar for the NoteEditor into this element */ + overflow-y: auto; + + /* Push the tag editor to the bottom of the note editor */ + flex-grow: 1; } diff --git a/ts/editor/FieldsEditor.svelte b/ts/editor/FieldsEditor.svelte deleted file mode 100644 index 2a7222088..000000000 --- a/ts/editor/FieldsEditor.svelte +++ /dev/null @@ -1,16 +0,0 @@ - -
- -
- - diff --git a/ts/editor/LabelContainer.svelte b/ts/editor/LabelContainer.svelte index df28d2d5d..b67ed1fbb 100644 --- a/ts/editor/LabelContainer.svelte +++ b/ts/editor/LabelContainer.svelte @@ -37,16 +37,13 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html diff --git a/ts/editor/editor-toolbar/EditorToolbar.svelte b/ts/editor/editor-toolbar/EditorToolbar.svelte index bf911fbef..3c3986835 100644 --- a/ts/editor/editor-toolbar/EditorToolbar.svelte +++ b/ts/editor/editor-toolbar/EditorToolbar.svelte @@ -53,7 +53,6 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html import ButtonToolbar from "../../components/ButtonToolbar.svelte"; import DynamicallySlottable from "../../components/DynamicallySlottable.svelte"; import Item from "../../components/Item.svelte"; - import StickyContainer from "../../components/StickyContainer.svelte"; import BlockButtons from "./BlockButtons.svelte"; import InlineButtons from "./InlineButtons.svelte"; import NotetypeButtons from "./NotetypeButtons.svelte"; @@ -85,7 +84,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html setContextProperty(api); - +
@@ -111,4 +110,14 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html - +
+ + diff --git a/ts/sveltelib/portal.ts b/ts/sveltelib/portal.ts index 8f045942f..e0de44ee2 100644 --- a/ts/sveltelib/portal.ts +++ b/ts/sveltelib/portal.ts @@ -7,11 +7,11 @@ */ function portal( element: HTMLElement, - targetElement: Element = document.body, + targetElement: Element | null = document.body, ): { update(target: Element): void; destroy(): void } { - let target: Element; + let target: Element | null; - async function update(newTarget: Element) { + async function update(newTarget: Element | null) { target = newTarget; if (!target) { diff --git a/ts/tag-editor/TagEditor.svelte b/ts/tag-editor/TagEditor.svelte index c2ceb6d6b..9438395ec 100644 --- a/ts/tag-editor/TagEditor.svelte +++ b/ts/tag-editor/TagEditor.svelte @@ -382,7 +382,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html $: anyTagsSelected = tagTypes.some((tag) => tag.selected); -
+