Skip to content

Commit

Permalink
feat(editor): focus container on click
Browse files Browse the repository at this point in the history
  • Loading branch information
nikku committed Aug 17, 2022
1 parent bff07e1 commit fd5bea3
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions packages/form-js-editor/src/render/Renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,22 @@ export default class Renderer {
});
});

// emit poor mans <element.hover> event
// when hovering the form container
container.addEventListener('mouseover', function() {
eventBus.fire('element.hover');
});

// ensure we focus the container if the users clicks
// inside; this follows input focus handling closely
container.addEventListener('click', function(event) {

// force focus when clicking container
if (!container.contains(document.activeElement)) {
container.focus({ preventScroll: true });
}
});

eventBus.on('element.hover', function() {
if (document.activeElement === document.body) {
container.focus({ preventScroll: true });
Expand Down

0 comments on commit fd5bea3

Please sign in to comment.