Browse Source

fix: bind text to correct container when nested (#5307)

* fix: bind text to correct container when nested

* fix tests
pull/5309/head
Aakansha Doshi 4 years ago committed by GitHub
parent
commit
ec35d5db51
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      src/components/App.tsx
  2. 3
      src/element/textWysiwyg.test.tsx

7
src/components/App.tsx

@ -2224,12 +2224,13 @@ class App extends React.Component<AppProps, AppState> { @@ -2224,12 +2224,13 @@ class App extends React.Component<AppProps, AppState> {
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 (

3
src/element/textWysiwyg.test.tsx

@ -115,6 +115,9 @@ describe("textWysiwyg", () => { @@ -115,6 +115,9 @@ describe("textWysiwyg", () => {
height: textSize,
containerId: container.id,
});
mutateElement(container, {
boundElements: [{ type: "text", id: text.id }],
});
h.elements = [container, text];

Loading…
Cancel
Save