Skip to content

Build your personal knowledge base with Trilium Notes

fix(client): allow overriding position using getter (closes #1321)

Elian Doran2213c500c272
diff --git a/src/public/app/components/component.ts b/src/public/app/components/component.ts
index 416449fc76..e2897d1f37 100644
--- a/src/public/app/components/component.ts
+++ b/src/public/app/components/component.ts
@@ -18,7 +18,7 @@ export class TypedComponent<ChildT extends TypedComponent<ChildT>> {
children: ChildT[];
initialized: Promise<void> | null;
parent?: TypedComponent<any>;
- position!: number;
+ _position!: number;
constructor() {
this.componentId = `${this.sanitizedClassName}-${utils.randomString(8)}`;
@@ -31,6 +31,14 @@ export class TypedComponent<ChildT extends TypedComponent<ChildT>> {
return this.constructor.name.replace(/[^A-Z0-9]/gi, "_");
}
+ get position() {
+ return this._position;
+ }
+
+ set position(newPosition: number) {
+ this._position = newPosition;
+ }
+
setParent(parent: TypedComponent<any>) {
this.parent = parent;
return this;