Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/react-canvas-core/src/Toolkit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class Toolkit {

public static closest(element: Element, selector: string) {
if (!Element.prototype.closest) {
Element.prototype.closest = function(s) {
Element.prototype.closest = function (s) {
var el = this;

do {
Expand Down
6 changes: 6 additions & 0 deletions packages/react-canvas-core/src/core-actions/ActionEventBus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,10 @@ export class ActionEventBus {
action.options.fire(actionEvent as any);
}
}

clearKeys() {
_.forEach(Object.keys(this.keys), (key) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dont need the Object.keys, _.forEach will give the key as the second param in the callback

document.dispatchEvent(new KeyboardEvent('keyup', { key: key }));
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export class CanvasWidget extends React.Component<DiagramProps> {
ref: React.RefObject<HTMLDivElement>;
keyUp: any;
keyDown: any;
blur: any;
canvasListener: any;

constructor(props: DiagramProps) {
Expand Down Expand Up @@ -65,9 +66,13 @@ export class CanvasWidget extends React.Component<DiagramProps> {
this.keyUp = (event) => {
this.props.engine.getActionEventBus().fireAction({ event });
};
this.blur = () => {
this.props.engine.getActionEventBus().clearKeys();
};

document.addEventListener('keyup', this.keyUp);
document.addEventListener('keydown', this.keyDown);
document.addEventListener('blur', this.blur);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see other comments, also this needs to be deregistered in unmount

this.registerCanvas();
}

Expand Down