fix(client/floating_buttons): clipped by ribbon

This commit is contained in:
Elian Doran 2025-12-09 09:20:31 +02:00
parent 7fc3d413e5
commit d5d2815bdf
No known key found for this signature in database
2 changed files with 13 additions and 2 deletions

View File

@ -6,7 +6,7 @@
.floating-buttons-children, .floating-buttons-children,
.show-floating-buttons { .show-floating-buttons {
position: absolute; position: absolute;
top: var(--floating-buttons-vert-offset, 14px); top: calc(var(--floating-buttons-vert-offset, 14px) + var(--ribbon-height, 0));
inset-inline-end: var(--floating-buttons-horiz-offset, 10px); inset-inline-end: var(--floating-buttons-horiz-offset, 10px);
display: flex; display: flex;
flex-direction: row; flex-direction: row;

View File

@ -1,5 +1,5 @@
import { useCallback, useEffect, useMemo, useRef, useState } from "preact/hooks"; import { useCallback, useEffect, useMemo, useRef, useState } from "preact/hooks";
import { useNoteContext, useNoteProperty, useStaticTooltipWithKeyboardShortcut, useTriliumEvents } from "../react/hooks"; import { useElementSize, useNoteContext, useNoteProperty, useStaticTooltipWithKeyboardShortcut, useTriliumEvents } from "../react/hooks";
import "./style.css"; import "./style.css";
import { Indexed, numberObjectsInPlace } from "../../services/utils"; import { Indexed, numberObjectsInPlace } from "../../services/utils";
@ -42,6 +42,16 @@ export default function Ribbon() {
refresh(); refresh();
}, [ note, noteType, isReadOnlyTemporarilyDisabled ]); }, [ note, noteType, isReadOnlyTemporarilyDisabled ]);
// Manage height.
const containerRef = useRef<HTMLDivElement>(null);
const size = useElementSize(containerRef);
useEffect(() => {
if (!containerRef.current || !size) return;
const parentEl = containerRef.current.closest<HTMLDivElement>(".note-split");
if (!parentEl) return;
parentEl.style.setProperty("--ribbon-height", `${size.height}px`);
}, [ size ]);
// Automatically activate the first ribbon tab that needs to be activated whenever a note changes. // Automatically activate the first ribbon tab that needs to be activated whenever a note changes.
useEffect(() => { useEffect(() => {
if (!computedTabs) return; if (!computedTabs) return;
@ -65,6 +75,7 @@ export default function Ribbon() {
return ( return (
<div <div
ref={containerRef}
className={clsx("ribbon-container", noteContext?.viewScope?.viewMode !== "default" && "hidden-ext")} className={clsx("ribbon-container", noteContext?.viewScope?.viewMode !== "default" && "hidden-ext")}
style={{ contain: "none" }} style={{ contain: "none" }}
> >