fix(client/layout): content header height not properly resized when switching notes

This commit is contained in:
Elian Doran 2025-12-09 11:26:15 +02:00
parent 5770222304
commit bfcf85e0d2
No known key found for this signature in database
3 changed files with 7 additions and 24 deletions

View File

@ -498,10 +498,6 @@ type EventMappings = {
noteIds: string[];
};
refreshData: { ntxId: string | null | undefined };
contentSafeMarginChanged: {
top: number;
noteContext: NoteContext;
}
};
export type EventListener<T extends EventNames> = {

View File

@ -48,12 +48,6 @@ export default function FloatingButtons({ items }: FloatingButtonsProps) {
const [ visible, setVisible ] = useState(true);
useEffect(() => setVisible(true), [ note ]);
useTriliumEvent("contentSafeMarginChanged", (e) => {
if (e.noteContext === noteContext) {
setTop(e.top);
}
});
return (
<div className="floating-buttons no-print" style={{top}}>
<div className={`floating-buttons-children ${!visible ? "temporarily-hidden" : ""}`}>

View File

@ -59,27 +59,20 @@ export default class ContentHeader extends Container<BasicWidget> {
if (shouldFloat !== this.isFloating) {
this.isFloating = shouldFloat;
const parentEl = this.parentElement?.closest<HTMLDivElement>(".note-split");
if (shouldFloat) {
this.$widget.addClass("floating");
parentEl!.style.setProperty("--content-header-height", `${this.currentHeight}px`);
} else {
this.$widget.removeClass("floating");
parentEl!.style.removeProperty("--content-header-height");
}
}
}
updateSafeMargin() {
const newSafeMargin = Math.max(this.currentHeight - this.parentElement!.scrollTop, 0);
if (newSafeMargin !== this.currentSafeMargin) {
this.currentSafeMargin = newSafeMargin;
this.triggerEvent("contentSafeMarginChanged", {
top: newSafeMargin,
noteContext: this.noteContext!
});
const parentEl = this.parentElement?.closest<HTMLDivElement>(".note-split");
if (this.isFloating) {
parentEl!.style.setProperty("--content-header-height", `${this.currentHeight}px`);
} else {
parentEl!.style.removeProperty("--content-header-height");
}
}