Skip to content

Commit 7c1595a

Browse files
authored
DataGrid - Focused cell appearance is applied to non-editable CheckBox cells on mouse clicks (#30920)
1 parent c36516c commit 7c1595a

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

e2e/testcafe-devextreme/tests/dataGrid/common/focus/focus.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,3 +298,22 @@ test('DataGrid - FocusedRowChanged event isnt raised when the push API is used t
298298
},
299299
}));
300300
});
301+
302+
test('DataGrid - Focused cell appearance is applied to non-editable CheckBox cells on mouse clicks (T1282082)', async (t) => {
303+
const grid = new DataGrid(GRID_SELECTOR);
304+
305+
await t
306+
.click(grid.getDataCell(0, 0).element)
307+
.click(grid.getDataCell(0, 1).element)
308+
.click(grid.getDataCell(0, 0).element)
309+
.expect(grid.getDataCell(0, 0).isFocused)
310+
.notOk();
311+
}).before(async () => createWidget('dxDataGrid', {
312+
dataSource: [
313+
{ BoolOne: false, BoolTwo: false },
314+
],
315+
columns: [
316+
'BoolOne',
317+
'BoolTwo',
318+
],
319+
}));

packages/devextreme/js/__internal/grids/grid_core/keyboard_navigation/m_keyboard_navigation.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1415,6 +1415,7 @@ export class KeyboardNavigationController extends KeyboardNavigationControllerCo
14151415
private _clickTargetCellHandler(event, $cell) {
14161416
const column = this._getColumnByCellElement($cell);
14171417
const isCellEditMode = this._isCellEditMode();
1418+
const isEditing = this._editingController.isEditing();
14181419

14191420
this.setCellFocusType();
14201421

@@ -1449,14 +1450,18 @@ export class KeyboardNavigationController extends KeyboardNavigationControllerCo
14491450
const $target = event
14501451
&& $(event.target).closest(`${NON_FOCUSABLE_ELEMENTS_SELECTOR}, td`);
14511452
const skipFocusEvent = $target && $target.not($cell).is(NON_FOCUSABLE_ELEMENTS_SELECTOR);
1452-
const isEditor = !!column && !column.command && $cell.hasClass(EDITOR_CELL_CLASS);
1453-
const isDisabled = !isEditor && (!args.isHighlighted || skipFocusEvent);
1453+
const isEditCell = !column?.command
1454+
&& isEditing
1455+
&& $cell.hasClass(EDITOR_CELL_CLASS);
1456+
1457+
const isDisabled = !isEditCell
1458+
&& (!args.isHighlighted || skipFocusEvent);
14541459
this._focus($cell, isDisabled, skipFocusEvent);
14551460
}
14561461
} else {
14571462
this.setRowFocusType();
14581463
this.setFocusedRowIndex(args.prevRowIndex);
1459-
if (this._editingController.isEditing() && isCellEditMode) {
1464+
if (isEditing && isCellEditMode) {
14601465
this._closeEditCell();
14611466
}
14621467
}

0 commit comments

Comments
 (0)