fix(mindmap): pane resizer not always working

This commit is contained in:
Elian Doran 2025-03-22 16:47:01 +02:00
parent ab4e9db864
commit ccb98d69fa
No known key found for this signature in database

View File

@ -165,8 +165,7 @@ export default abstract class AbstractSplitTypeWidget extends TypeWidget {
}
cleanup(): void {
this.splitInstance?.destroy();
this.splitInstance = undefined;
this.#destroyResizer();
}
async doRefresh(note: FNote | null | undefined) {
@ -189,17 +188,19 @@ export default abstract class AbstractSplitTypeWidget extends TypeWidget {
// Vertical vs horizontal layout
const layoutOrientation = (!utils.isMobile() ? options.get("splitEditorOrientation") ?? "horizontal" : "vertical");
if (this.layoutOrientation === layoutOrientation && this.isReadOnly === isReadOnly) {
return;
if (this.layoutOrientation !== layoutOrientation || this.isReadOnly !== isReadOnly) {
this.$widget
.toggleClass("split-horizontal", !isReadOnly && layoutOrientation === "horizontal")
.toggleClass("split-vertical", !isReadOnly && layoutOrientation === "vertical")
.toggleClass("split-read-only", isReadOnly);
this.layoutOrientation = layoutOrientation as ("horizontal" | "vertical");
this.isReadOnly = isReadOnly;
this.#destroyResizer();
}
this.$widget
.toggleClass("split-horizontal", !isReadOnly && layoutOrientation === "horizontal")
.toggleClass("split-vertical", !isReadOnly && layoutOrientation === "vertical")
.toggleClass("split-read-only", isReadOnly);
this.layoutOrientation = layoutOrientation as ("horizontal" | "vertical");
this.isReadOnly = isReadOnly;
this.#setupResizer();
if (!this.splitInstance) {
this.#setupResizer();
}
}
#setupResizer() {
@ -226,6 +227,11 @@ export default abstract class AbstractSplitTypeWidget extends TypeWidget {
}
}
#destroyResizer() {
this.splitInstance?.destroy();
this.splitInstance = undefined;
}
/**
* Called upon when the split between the preview and content pane is initialized. Can be used to add additional listeners if needed.
*/