Skip to content

Commit fd5bea3

Browse files
committed
feat(editor): focus container on click
1 parent bff07e1 commit fd5bea3

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

packages/form-js-editor/src/render/Renderer.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,22 @@ export default class Renderer {
3636
});
3737
});
3838

39+
// emit poor mans <element.hover> event
40+
// when hovering the form container
41+
container.addEventListener('mouseover', function() {
42+
eventBus.fire('element.hover');
43+
});
44+
45+
// ensure we focus the container if the users clicks
46+
// inside; this follows input focus handling closely
47+
container.addEventListener('click', function(event) {
48+
49+
// force focus when clicking container
50+
if (!container.contains(document.activeElement)) {
51+
container.focus({ preventScroll: true });
52+
}
53+
});
54+
3955
eventBus.on('element.hover', function() {
4056
if (document.activeElement === document.body) {
4157
container.focus({ preventScroll: true });

0 commit comments

Comments
 (0)