From ec35d5db51cfe9bcb8ac5d16c640e05e6df020ba Mon Sep 17 00:00:00 2001 From: Aakansha Doshi Date: Wed, 15 Jun 2022 16:09:12 +0530 Subject: [PATCH] fix: bind text to correct container when nested (#5307) * fix: bind text to correct container when nested * fix tests --- src/components/App.tsx | 7 ++++--- src/element/textWysiwyg.test.tsx | 3 +++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/components/App.tsx b/src/components/App.tsx index e430026c..8cf5f522 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -2224,12 +2224,13 @@ class App extends React.Component { existingTextElement = selectedElements[0]; } else if (isTextBindableContainer(selectedElements[0], false)) { existingTextElement = getBoundTextElement(selectedElements[0]); + } else { + existingTextElement = this.getTextElementAtPosition(sceneX, sceneY); } + } else { + existingTextElement = this.getTextElementAtPosition(sceneX, sceneY); } - existingTextElement = - existingTextElement ?? this.getTextElementAtPosition(sceneX, sceneY); - // bind to container when shouldBind is true or // clicked on center of container if ( diff --git a/src/element/textWysiwyg.test.tsx b/src/element/textWysiwyg.test.tsx index ae7f1341..de7528be 100644 --- a/src/element/textWysiwyg.test.tsx +++ b/src/element/textWysiwyg.test.tsx @@ -115,6 +115,9 @@ describe("textWysiwyg", () => { height: textSize, containerId: container.id, }); + mutateElement(container, { + boundElements: [{ type: "text", id: text.id }], + }); h.elements = [container, text];