瀏覽代碼

fix: switch cursor to center of container when adding text when dimensions are too small (#4452)

Aakansha Doshi 3 年之前
父節點
當前提交
089b05db1b
共有 1 個文件被更改,包括 10 次插入1 次删除
  1. 10 1
      src/components/App.tsx

+ 10 - 1
src/components/App.tsx

@@ -2066,7 +2066,7 @@ class App extends React.Component<AppProps, AppState> {
     /** whether to attempt to insert at element center if applicable */
     insertAtParentCenter?: boolean;
   }) => {
-    const parentCenterPosition =
+    let parentCenterPosition =
       insertAtParentCenter &&
       this.getTextWysiwygSnappedToCenterPosition(
         sceneX,
@@ -2111,6 +2111,15 @@ class App extends React.Component<AppProps, AppState> {
       mutateElement(container, { height: newHeight, width: newWidth });
       sceneX = container.x + newWidth / 2;
       sceneY = container.y + newHeight / 2;
+      if (parentCenterPosition) {
+        parentCenterPosition = this.getTextWysiwygSnappedToCenterPosition(
+          sceneX,
+          sceneY,
+          this.state,
+          this.canvas,
+          window.devicePixelRatio,
+        );
+      }
     }
 
     const element = existingTextElement