Skip to content

Commit bb4fd50

Browse files
committed
fix(editor): don't prevent click bubbling
(A better fix would be using proper event delegation, but OK...)
1 parent fd5bea3 commit bb4fd50

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

packages/form-js-editor/src/render/components/FormEditor.js

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,22 @@ function Element(props) {
7878
return () => eventBus.off('selection.changed', scrollIntoView);
7979
}, [ id ]);
8080

81-
function onClick(event) {
82-
event.stopPropagation();
81+
const onClick = useCallback((event) => {
82+
83+
// TODO(nikku): refactor this to use proper DOM delegation
84+
const fieldEl = event.target.closest('[data-id]');
85+
86+
if (!fieldEl) {
87+
return;
88+
}
89+
90+
const id = fieldEl.dataset.id;
91+
92+
if (id === field.id) {
93+
selection.toggle(field);
94+
}
95+
}, [ field ]);
8396

84-
selection.toggle(field);
85-
}
8697

8798
const classes = [ 'fjs-element' ];
8899

0 commit comments

Comments
 (0)