Skip to content

Commit

Permalink
DataGrid: Fix keyboard event bubbling when pressing escape key (T1202…
Browse files Browse the repository at this point in the history
…731) (#26127)

Co-authored-by: Alyar <>
  • Loading branch information
Alyar666 authored Dec 5, 2023
1 parent 450cdaa commit e08b2a5
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -469,15 +469,18 @@ export const focusModule = {
this.option('focusedColumnIndex', columnIndex);
},

_escapeKeyHandler(eventArgs, isEditing) {
_escapeKeyHandler(eventArgs, isEditing): boolean {
if (isEditing || !this.option('focusedRowEnabled')) {
this.callBase(eventArgs, isEditing);
return;
return this.callBase(eventArgs, isEditing);
}
if (this.isCellFocusType()) {
this.setRowFocusType();
this._focus(this._getCellElementFromTarget(eventArgs.originalEvent.target), true);

return true;
}

return false;
},

_updateFocusedCellPosition($cell, direction) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -472,8 +472,7 @@ export class KeyboardNavigationController extends modules.ViewController {
break;

case 'escape':
this._escapeKeyHandler(e, isEditing);
isHandled = true;
isHandled = this._escapeKeyHandler(e, isEditing);
break;

case 'F':
Expand Down Expand Up @@ -1060,7 +1059,7 @@ export class KeyboardNavigationController extends modules.ViewController {
}
}

_escapeKeyHandler(eventArgs, isEditing) {
_escapeKeyHandler(eventArgs, isEditing): boolean {
const $cell = this._getCellElementFromTarget(
eventArgs.originalEvent.target,
);
Expand All @@ -1081,7 +1080,11 @@ export class KeyboardNavigationController extends modules.ViewController {
}
}
eventArgs.originalEvent.preventDefault();

return true;
}

return false;
}

_ctrlFKeyHandler(eventArgs) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2064,6 +2064,24 @@ QUnit.module('Keyboard keys', {
assert.ok(!this.editingController.hasEditData(), 'grid hasn\'t unsaved data');
});

// T1202731
QUnit.testInActiveWindow('Escape should bubble up when any grid action was not executed', function(assert) {
// arrange
const $container = $('#container');

setupModules(this);

this.gridView.render($container);
this.focusFirstCell();

const e = $.Event('keydown', { key: 'escape' });
$($container.find('.dx-datagrid-rowsview')).trigger(e);
this.clock.tick(10);

// assert
assert.ok(!e.isPropagationStopped(), 'propagation is not stopped');
});

QUnit.testInActiveWindow('Editing by enter key is not worked when editing is disabled', function(assert) {
// arrange
const $container = $('#container');
Expand Down

0 comments on commit e08b2a5

Please sign in to comment.