Skip to content

Commit

Permalink
fix: bounds cached prematurely resulting in incorrectly rendered labe…
Browse files Browse the repository at this point in the history
…ls (#7339)
  • Loading branch information
dwelle committed Dec 4, 2023
1 parent ddb7585 commit de983c1
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/element/bounds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { getBoundTextElement, getContainerElement } from "./textElement";
import { LinearElementEditor } from "./linearElementEditor";
import { Mutable } from "../utility-types";
import { ShapeCache } from "../scene/ShapeCache";
import Scene from "../scene/Scene";

export type RectangleBox = {
x: number;
Expand Down Expand Up @@ -59,10 +60,17 @@ export class ElementBounds {

const bounds = ElementBounds.calculateBounds(element);

ElementBounds.boundsCache.set(element, {
version: element.version,
bounds,
});
// hack to ensure that downstream checks could retrieve element Scene
// so as to have correctly calculated bounds
// FIXME remove when we get rid of all the id:Scene / element:Scene mapping
const shouldCache = Scene.getScene(element);

if (shouldCache) {
ElementBounds.boundsCache.set(element, {
version: element.version,
bounds,
});
}

return bounds;
}
Expand Down

0 comments on commit de983c1

Please sign in to comment.