mirror of
https://github.com/zadam/trilium.git
synced 2025-12-12 10:24:23 +01:00
fix(client/layout): content header height not properly resized when switching notes
This commit is contained in:
parent
5770222304
commit
bfcf85e0d2
@ -498,10 +498,6 @@ type EventMappings = {
|
|||||||
noteIds: string[];
|
noteIds: string[];
|
||||||
};
|
};
|
||||||
refreshData: { ntxId: string | null | undefined };
|
refreshData: { ntxId: string | null | undefined };
|
||||||
contentSafeMarginChanged: {
|
|
||||||
top: number;
|
|
||||||
noteContext: NoteContext;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export type EventListener<T extends EventNames> = {
|
export type EventListener<T extends EventNames> = {
|
||||||
|
|||||||
@ -48,12 +48,6 @@ export default function FloatingButtons({ items }: FloatingButtonsProps) {
|
|||||||
const [ visible, setVisible ] = useState(true);
|
const [ visible, setVisible ] = useState(true);
|
||||||
useEffect(() => setVisible(true), [ note ]);
|
useEffect(() => setVisible(true), [ note ]);
|
||||||
|
|
||||||
useTriliumEvent("contentSafeMarginChanged", (e) => {
|
|
||||||
if (e.noteContext === noteContext) {
|
|
||||||
setTop(e.top);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="floating-buttons no-print" style={{top}}>
|
<div className="floating-buttons no-print" style={{top}}>
|
||||||
<div className={`floating-buttons-children ${!visible ? "temporarily-hidden" : ""}`}>
|
<div className={`floating-buttons-children ${!visible ? "temporarily-hidden" : ""}`}>
|
||||||
|
|||||||
@ -59,27 +59,20 @@ export default class ContentHeader extends Container<BasicWidget> {
|
|||||||
if (shouldFloat !== this.isFloating) {
|
if (shouldFloat !== this.isFloating) {
|
||||||
this.isFloating = shouldFloat;
|
this.isFloating = shouldFloat;
|
||||||
|
|
||||||
const parentEl = this.parentElement?.closest<HTMLDivElement>(".note-split");
|
|
||||||
if (shouldFloat) {
|
if (shouldFloat) {
|
||||||
this.$widget.addClass("floating");
|
this.$widget.addClass("floating");
|
||||||
parentEl!.style.setProperty("--content-header-height", `${this.currentHeight}px`);
|
|
||||||
} else {
|
} else {
|
||||||
this.$widget.removeClass("floating");
|
this.$widget.removeClass("floating");
|
||||||
parentEl!.style.removeProperty("--content-header-height");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
updateSafeMargin() {
|
updateSafeMargin() {
|
||||||
const newSafeMargin = Math.max(this.currentHeight - this.parentElement!.scrollTop, 0);
|
const parentEl = this.parentElement?.closest<HTMLDivElement>(".note-split");
|
||||||
|
if (this.isFloating) {
|
||||||
if (newSafeMargin !== this.currentSafeMargin) {
|
parentEl!.style.setProperty("--content-header-height", `${this.currentHeight}px`);
|
||||||
this.currentSafeMargin = newSafeMargin;
|
} else {
|
||||||
|
parentEl!.style.removeProperty("--content-header-height");
|
||||||
this.triggerEvent("contentSafeMarginChanged", {
|
|
||||||
top: newSafeMargin,
|
|
||||||
noteContext: this.noteContext!
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user