fix: change which element keydown is bound to from document to injection div (#8188)

* Change which element keydown is bound to

* Modify keydown tests

* Use browserEvents.conditionalBind()

* Remove commented out code.
This commit is contained in:
Mark Friedman
2024-05-31 15:19:46 -07:00
committed by GitHub
parent 547bf2373d
commit 5881ce32c1
2 changed files with 17 additions and 17 deletions

View File

@@ -77,6 +77,8 @@ export function inject(
common.setMainWorkspace(workspace);
});
browserEvents.conditionalBind(subContainer, 'keydown', null, onKeyDown);
return workspace;
}
@@ -320,8 +322,6 @@ let documentEventsBound = false;
* Most of these events should be bound to the SVG's surface.
* However, 'mouseup' has to be on the whole document so that a block dragged
* out of bounds and released will know that it has been released.
* Also, 'keydown' has to be on the whole document since the browser doesn't
* understand a concept of focus on the SVG image.
*/
function bindDocumentEvents() {
if (!documentEventsBound) {
@@ -333,7 +333,6 @@ function bindDocumentEvents() {
}
}
});
browserEvents.conditionalBind(document, 'keydown', null, onKeyDown);
// longStop needs to run to stop the context menu from showing up. It
// should run regardless of what other touch event handlers have run.
browserEvents.bind(document, 'touchend', null, Touch.longStop);