From 45a57d70de75fbb47f7c3c45cae675341c9bcab5 Mon Sep 17 00:00:00 2001
From: Aakansha Doshi <aakansha1216@gmail.com>
Date: Wed, 26 Apr 2023 21:35:06 +0530
Subject: [PATCH] fix: don't refresh dimensions for text containers on font
 load (#6523)

---
 src/data/blob.ts                 | 2 +-
 src/excalidraw-app/data/index.ts | 2 +-
 src/scene/Fonts.ts               | 3 ++-
 3 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/data/blob.ts b/src/data/blob.ts
index 4565b5cb..c0aa66ee 100644
--- a/src/data/blob.ts
+++ b/src/data/blob.ts
@@ -155,7 +155,7 @@ export const loadSceneOrLibraryFromBlob = async (
           },
           localAppState,
           localElements,
-          { repairBindings: true, refreshDimensions: true },
+          { repairBindings: true, refreshDimensions: false },
         ),
       };
     } else if (isValidLibrary(data)) {
diff --git a/src/excalidraw-app/data/index.ts b/src/excalidraw-app/data/index.ts
index 7f13bc61..2e50abf1 100644
--- a/src/excalidraw-app/data/index.ts
+++ b/src/excalidraw-app/data/index.ts
@@ -263,7 +263,7 @@ export const loadScene = async (
       await importFromBackend(id, privateKey),
       localDataState?.appState,
       localDataState?.elements,
-      { repairBindings: true, refreshDimensions: true },
+      { repairBindings: true, refreshDimensions: false },
     );
   } else {
     data = restore(localDataState || null, null, null, {
diff --git a/src/scene/Fonts.ts b/src/scene/Fonts.ts
index cc206c77..e245eb16 100644
--- a/src/scene/Fonts.ts
+++ b/src/scene/Fonts.ts
@@ -1,5 +1,6 @@
 import { isTextElement, refreshTextDimensions } from "../element";
 import { newElementWith } from "../element/mutateElement";
+import { isBoundToContainer } from "../element/typeChecks";
 import { ExcalidrawElement, ExcalidrawTextElement } from "../element/types";
 import { invalidateShapeForElement } from "../renderer/renderElement";
 import { getFontString } from "../utils";
@@ -52,7 +53,7 @@ export class Fonts {
     let didUpdate = false;
 
     this.scene.mapElements((element) => {
-      if (isTextElement(element)) {
+      if (isTextElement(element) && !isBoundToContainer(element)) {
         invalidateShapeForElement(element);
         didUpdate = true;
         return newElementWith(element, {