Skip to content

Commit 59700fa

Browse files
AntamansidAntamansid
andauthored
fix: update anchors before geometry to fix React positioning (#98)
Co-authored-by: Antamansid <[email protected]>
1 parent dcf8000 commit 59700fa

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/store/block/Block.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { computed, signal } from "@preact/signals-core";
21
import type { Signal } from "@preact/signals-core";
2+
import { computed, signal } from "@preact/signals-core";
33
import cloneDeep from "lodash/cloneDeep";
44

55
import { TAnchor } from "../../components/canvas/anchors";
@@ -143,10 +143,12 @@ export class BlockState<T extends TBlock = TBlock> {
143143
}
144144

145145
public updateBlock(block: Partial<TBlock>): void {
146-
this.$state.value = Object.assign({}, this.$state.value, block);
146+
// Update anchors first to ensure they have correct state when geometry changes
147147
if (block.anchors) {
148148
this.updateAnchors(block.anchors);
149149
}
150+
151+
this.$state.value = Object.assign({}, this.$state.value, block);
150152
this.getViewComponent()?.updateHitBox(this.$geometry.value, true);
151153
}
152154

0 commit comments

Comments
 (0)