Skip to content

Commit

Permalink
fix(editor): don't prevent click bubbling
Browse files Browse the repository at this point in the history
(A better fix would be using proper event delegation, but OK...)
  • Loading branch information
nikku committed Aug 18, 2022
1 parent 359101b commit 03ff686
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions packages/form-js-editor/src/render/components/FormEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,22 @@ function Element(props) {
return () => eventBus.off('selection.changed', scrollIntoView);
}, [ id ]);

function onClick(event) {
event.stopPropagation();
const onClick = useCallback((event) => {

// TODO(nikku): refactor this to use proper DOM delegation
const fieldEl = event.target.closest('[data-id]');

if (!fieldEl) {
return;
}

const id = fieldEl.dataset.id;

if (id === field.id) {
selection.toggle(field);
}
}, [ field ]);

selection.toggle(field);
}

const classes = [ 'fjs-element' ];

Expand Down

0 comments on commit 03ff686

Please sign in to comment.