Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -6724,3 +6724,63 @@ test('Focus should be set to the grid to allow keyboard navigation when the focu
},
}, '#otherContainer');
});

[true, false].forEach((focusedRowEnabled) => {
test(`Focus should return to the last active cell when re-entering the rowsview via kbn if focusedRowEnabled=${focusedRowEnabled} (T1308919)`, async (t) => {
// arrange
const button = new Button('#otherContainer');
const dataGrid = new DataGrid('#container');
const searchPanel = dataGrid.getSearchBox();
const secondIDCell = dataGrid.getDataCell(1, 0);
const secondNameCell = dataGrid.getDataCell(1, 1);

// assert
await t.expect(dataGrid.isReady()).ok();

// act
await t
.click(searchPanel.input)
.pressKey('tab tab tab tab tab');

// assert
await t.expect(secondIDCell.isFocused).ok();

// act
await searchPanel.focus();

// assert
await t
.expect(searchPanel.isFocused)
.ok()
.expect(secondIDCell.isFocused)
.notOk('focus should be on the search panel');

// act
await t.pressKey('tab tab tab');

// assert
await t.expect(secondIDCell.isFocused).ok();

// act
await t.pressKey('tab tab');

// assert
await t.expect(button.isFocused).ok();

// act
await t.pressKey('shift+tab');

// assert
await t.expect(secondNameCell.isFocused).ok();
}).before(async () => {
await createWidget('dxDataGrid', {
dataSource: [{ id: 1, name: 'test1' }, { id: 2, name: 'test2' }],
keyExpr: 'id',
focusedRowEnabled,
searchPanel: { visible: true },
});
await createWidget('dxButton', {
text: 'Focus receiver',
}, '#otherContainer');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -1647,17 +1647,13 @@ export class KeyboardNavigationController extends KeyboardNavigationControllerCo

// #region Focusing
public focus(element) {
let activeElementSelector;
const focusedRowEnabled = this.option('focusedRowEnabled');
const isHighlighted = this._isCellElement($(element));

if (!element) {
activeElementSelector = `.${this.addWidgetPrefix(ROWS_VIEW_CLASS)} .dx-row[tabindex]`;
if (!focusedRowEnabled) {
activeElementSelector
+= `, .${this.addWidgetPrefix(ROWS_VIEW_CLASS)} .dx-row > td[tabindex]`;
}
element = this.component.$element().find(activeElementSelector).first();
const activeRowSelector = `.${this.addWidgetPrefix(ROWS_VIEW_CLASS)} .dx-row[tabindex]`;
const activeCellSelector = `.${this.addWidgetPrefix(ROWS_VIEW_CLASS)} .dx-row > td[tabindex]`;
const selectors = [activeRowSelector, activeCellSelector].join(', ');
element = this.component.$element().find(selectors).first();
Comment thread
markallenramirez marked this conversation as resolved.
}

element && this._focusElement($(element), isHighlighted);
Expand Down Expand Up @@ -1785,12 +1781,6 @@ export class KeyboardNavigationController extends KeyboardNavigationControllerCo
$focusElement
.removeClass(CELL_FOCUS_DISABLED_CLASS)
.removeClass(FOCUSED_CLASS);

const isTargetInGrid = gridCoreUtils.isElementInCurrentGrid(this, $(e.relatedTarget));
if (!isTargetInGrid) {
this._resetFocusedCell(true);
this._resetFocusedView();
}
}
});
if (!skipFocusEvent) {
Expand Down
Loading