Skip to content

Commit 8b10634

Browse files
authored
fix: prevent checkbox and radio changing in design mode (#5233)
User can click on checkboxes and radio inputs on canvas and make them checked. We don't want this in design mode.
1 parent 57ea5da commit 8b10634

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

apps/builder/app/canvas/interceptor.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,12 @@ const switchPageAndUpdateSystem = (href: string, formData?: FormData) => {
7676

7777
export const subscribeInterceptedEvents = () => {
7878
const handleClick = (event: MouseEvent) => {
79-
// Prevent forwarding the click event on an input element when the associated label has a "for" attribute
80-
if (
81-
event.target instanceof Element &&
82-
event.target.closest("label[for]") &&
83-
!$isPreviewMode.get()
84-
) {
85-
event.preventDefault();
79+
if (event.target instanceof Element && !$isPreviewMode.get()) {
80+
// Prevent forwarding the click event on an input element when the associated label has a "for" attribute
81+
// and prevent checkbox or radio inputs changing when clicked
82+
if (event.target.closest("label[for]") || event.target.closest("input")) {
83+
event.preventDefault();
84+
}
8685
}
8786

8887
if (

0 commit comments

Comments
 (0)