Skip to content

Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.

Fix button duplicate text on edit (#2066)

Ivan Starkovda7e17b2fe70
diff --git a/apps/builder/app/canvas/features/webstudio-component/webstudio-component.tsx b/apps/builder/app/canvas/features/webstudio-component/webstudio-component.tsx
index 9ea4c115e4..e376e32e04 100644
--- a/apps/builder/app/canvas/features/webstudio-component/webstudio-component.tsx
+++ b/apps/builder/app/canvas/features/webstudio-component/webstudio-component.tsx
@@ -73,9 +73,16 @@ const ContentEditable = ({
}
if (rootElement?.tagName === "BUTTON") {
+ // button with contentEditable does not let to press space
+ // so add span inside and use it as editor element in lexical
const span = document.createElement("span");
span.contentEditable = "true";
+ const child = rootElement.firstChild;
+ if (child !== null) {
+ span.appendChild(child);
+ }
rootElement.appendChild(span);
+
rootElement = span;
}
if (rootElement) {