fix: don't allow whitespaces for bound text (#5939)
* fix: don't allow whitespaces for bound text * fix * remove * remove empty else * fix * fix * fix
This commit is contained in:
parent
8b33ca3a1a
commit
1933116261
@ -1196,5 +1196,18 @@ describe("textWysiwyg", () => {
|
|||||||
]);
|
]);
|
||||||
expect(text.containerId).toBe(rectangle.id);
|
expect(text.containerId).toBe(rectangle.id);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should not allow bound text with only whitespaces", async () => {
|
||||||
|
Keyboard.keyPress(KEYS.ENTER);
|
||||||
|
const editor = document.querySelector(
|
||||||
|
".excalidraw-textEditorContainer > textarea",
|
||||||
|
) as HTMLTextAreaElement;
|
||||||
|
await new Promise((r) => setTimeout(r, 0));
|
||||||
|
|
||||||
|
fireEvent.change(editor, { target: { value: " " } });
|
||||||
|
editor.blur();
|
||||||
|
expect(rectangle.boundElements).toBeNull();
|
||||||
|
expect(h.elements[1].isDeleted).toBe(true);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -10,8 +10,8 @@ import { isBoundToContainer, isTextElement } from "./typeChecks";
|
|||||||
import { CLASSES, BOUND_TEXT_PADDING, VERTICAL_ALIGN } from "../constants";
|
import { CLASSES, BOUND_TEXT_PADDING, VERTICAL_ALIGN } from "../constants";
|
||||||
import {
|
import {
|
||||||
ExcalidrawElement,
|
ExcalidrawElement,
|
||||||
ExcalidrawTextElement,
|
|
||||||
ExcalidrawLinearElement,
|
ExcalidrawLinearElement,
|
||||||
|
ExcalidrawTextElement,
|
||||||
} from "./types";
|
} from "./types";
|
||||||
import { AppState } from "../types";
|
import { AppState } from "../types";
|
||||||
import { mutateElement } from "./mutateElement";
|
import { mutateElement } from "./mutateElement";
|
||||||
@ -510,7 +510,7 @@ export const textWysiwyg = ({
|
|||||||
|
|
||||||
if (container) {
|
if (container) {
|
||||||
text = updateElement.text;
|
text = updateElement.text;
|
||||||
if (editable.value) {
|
if (editable.value.trim()) {
|
||||||
const boundTextElementId = getBoundTextElementId(container);
|
const boundTextElementId = getBoundTextElementId(container);
|
||||||
if (!boundTextElementId || boundTextElementId !== element.id) {
|
if (!boundTextElementId || boundTextElementId !== element.id) {
|
||||||
mutateElement(container, {
|
mutateElement(container, {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user