Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correctly listen for <Escape> to cancel dragging #709

Merged
merged 1 commit into from
Nov 23, 2022
Merged
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 lib/features/dragging/Dragging.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ export default function Dragging(eventBus, canvas, selection, elementRegistry) {

function checkCancel(event) {

if (isKey('Escape')) {
if (isKey('Escape', event)) {
preventDefault(event);

cancel();
Expand Down
26 changes: 26 additions & 0 deletions test/spec/features/dragging/DraggingSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import zoomScrollModule from 'lib/navigation/zoomscroll';
import createModule from 'lib/features/create';
import modelingModule from 'lib/features/modeling';

import { createKeyEvent } from 'test/util/KeyEvents';

import { classes as svgClasses } from 'tiny-svg';


Expand Down Expand Up @@ -428,6 +430,30 @@ describe('features/dragging - Dragging', function() {
});


describe('features/dragging - keyboard integration', function() {

beforeEach(bootstrapDiagram({
modules: [
dragModule
]
}));


it('should cancel on <Escape>', inject(function(dragging) {

// given
dragging.init(canvasEvent({ x: 10, y: 10 }), 'foo');

// when
document.dispatchEvent(createKeyEvent('Escape', { type: 'keyup' }));

// then
expect(dragging.context()).not.to.exist;
}));

});


describe('features/dragging - error Handling', function() {

beforeEach(bootstrapDiagram({
Expand Down