From e296416a548750105b290c980bfc8144476e0280 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sat, 13 Dec 2025 14:38:58 +0200 Subject: [PATCH] fix(layout/inline-title): title not shown when switching to other types of notes --- .../client/src/widgets/layout/InlineTitle.css | 38 +++++++++---------- .../client/src/widgets/layout/InlineTitle.tsx | 22 ++++++----- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/apps/client/src/widgets/layout/InlineTitle.css b/apps/client/src/widgets/layout/InlineTitle.css index 447178c52..a6000910e 100644 --- a/apps/client/src/widgets/layout/InlineTitle.css +++ b/apps/client/src/widgets/layout/InlineTitle.css @@ -1,3 +1,7 @@ +:root { + --title-transition: opacity 200ms ease-in; +} + .component.inline-title { contain: none; } @@ -9,6 +13,12 @@ & > .inline-title-row { display: flex; align-items: center; + transition: var(--title-transition); + + &.hidden { + opacity: 0; + pointer-events: none; + } } &.hidden { @@ -20,28 +30,16 @@ } } -.note-split > .title-row .note-icon-widget, -.note-split > .title-row .note-title-widget, -.inline-title > .inline-title-row { - transition: opacity 200ms ease-in; -} - -.note-split { - &.inline-title-visible { - &> .title-row { - .note-icon-widget, - .note-title-widget { - opacity: 0; - pointer-events: none; - } - } +.title-row { + &.note-icon-widget, + &.note-title-widget { + transition: var(--title-transition); } - &:not(.inline-title-visible) { - .inline-title .inline-title-row { - opacity: 0; - pointer-events: none; - } + &.hide-title .note-icon-widget, + &.hide-title .note-title-widget { + opacity: 0; + pointer-events: none; } } diff --git a/apps/client/src/widgets/layout/InlineTitle.tsx b/apps/client/src/widgets/layout/InlineTitle.tsx index 5eb5e60cc..31f445504 100644 --- a/apps/client/src/widgets/layout/InlineTitle.tsx +++ b/apps/client/src/widgets/layout/InlineTitle.tsx @@ -3,7 +3,7 @@ import "./InlineTitle.css"; import { NoteType } from "@triliumnext/commons"; import clsx from "clsx"; import { ComponentChild } from "preact"; -import { useEffect, useMemo, useRef, useState } from "preact/hooks"; +import { useEffect, useLayoutEffect, useMemo, useRef, useState } from "preact/hooks"; import { Trans } from "react-i18next"; import FNote from "../../entities/fnote"; @@ -31,21 +31,23 @@ export default function InlineTitle() { const { note, parentComponent, viewScope } = useNoteContext(); const type = useNoteProperty(note, "type"); const [ shown, setShown ] = useState(shouldShow(note?.noteId, type, viewScope)); - const containerRef= useRef(null); + const containerRef = useRef(null); + const [ titleHidden, setTitleHidden ] = useState(false); - useEffect(() => { + useLayoutEffect(() => { setShown(shouldShow(note?.noteId, type, viewScope)); }, [ note, type, viewScope ]); - useEffect(() => { + useLayoutEffect(() => { if (!shown) return; - const noteSplit = parentComponent.$widget[0].closest(".note-split"); - const titleRow = noteSplit?.querySelector("&> .title-row"); - if (!noteSplit || !titleRow) return; + const titleRow = parentComponent.$widget[0].closest(".note-split")?.querySelector("&> .title-row"); + if (!titleRow) return; + titleRow.classList.toggle("hide-title", true); const observer = new IntersectionObserver((entries) => { - noteSplit.classList.toggle("inline-title-visible", entries[0].isIntersecting); + titleRow.classList.toggle("hide-title", entries[0].isIntersecting); + setTitleHidden(!entries[0].isIntersecting); }, { threshold: 0.85 }); @@ -54,7 +56,7 @@ export default function InlineTitle() { } return () => { - noteSplit.classList.remove("inline-title-visible"); + titleRow.classList.remove("hide-title"); observer.disconnect(); }; }, [ shown, parentComponent ]); @@ -64,7 +66,7 @@ export default function InlineTitle() { ref={containerRef} className={clsx("inline-title", !shown && "hidden")} > -
+