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: prevent checkbox and radio changing in design mode (#5233)

Bogdan Chadkin8b1063425cbc
diff --git a/apps/builder/app/canvas/interceptor.ts b/apps/builder/app/canvas/interceptor.ts
index c7d42c4f7c..3421c63d85 100644
--- a/apps/builder/app/canvas/interceptor.ts
+++ b/apps/builder/app/canvas/interceptor.ts
@@ -76,13 +76,12 @@ const switchPageAndUpdateSystem = (href: string, formData?: FormData) => {
export const subscribeInterceptedEvents = () => {
const handleClick = (event: MouseEvent) => {
- // Prevent forwarding the click event on an input element when the associated label has a "for" attribute
- if (
- event.target instanceof Element &&
- event.target.closest("label[for]") &&
- !$isPreviewMode.get()
- ) {
- event.preventDefault();
+ if (event.target instanceof Element && !$isPreviewMode.get()) {
+ // Prevent forwarding the click event on an input element when the associated label has a "for" attribute
+ // and prevent checkbox or radio inputs changing when clicked
+ if (event.target.closest("label[for]") || event.target.closest("input")) {
+ event.preventDefault();
+ }
}
if (