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

DataGrid(T1171870): DataGrid - The 'dx-focused' class is not removed from a grid cell when it loses focus. #24918

Merged
merged 3 commits into from
Jun 23, 2023
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 @@ -26,6 +26,7 @@ export const DATEBOX_WIDGET_NAME = 'dxDateBox';
export const FOCUS_STATE_CLASS = 'dx-state-focused';
export const WIDGET_CLASS = 'dx-widget';
export const REVERT_BUTTON_CLASS = 'dx-revert-button';
export const FOCUSED_CLASS = 'dx-focused';

export const FAST_EDITING_DELETE_KEY = 'delete';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import {
FOCUS_STATE_CLASS,
FOCUS_TYPE_CELL,
FOCUS_TYPE_ROW,
FOCUSED_CLASS,
FREESPACE_ROW_CLASS,
FUNCTIONAL_KEYS,
GROUP_FOOTER_CLASS,
Expand Down Expand Up @@ -1306,13 +1307,16 @@ export class KeyboardNavigationController extends modules.ViewController {
.find('.dx-row[tabindex], .dx-row > td[tabindex]')
.not($focusElement)
.removeClass(CELL_FOCUS_DISABLED_CLASS)
.removeClass(FOCUSED_CLASS)
.removeAttr('tabindex');
}

// @ts-expect-error
eventsEngine.one($focusElement, 'blur', (e) => {
if (e.relatedTarget) {
$focusElement.removeClass(CELL_FOCUS_DISABLED_CLASS);
$focusElement
.removeClass(CELL_FOCUS_DISABLED_CLASS)
.removeClass(FOCUSED_CLASS);
}
});
if (!skipFocusEvent) {
Expand Down
35 changes: 35 additions & 0 deletions testing/testcafe/tests/dataGrid/focus/focus.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import createWidget from '../../../helpers/createWidget';
import url from '../../../helpers/getPageUrl';
import DataGrid from '../../../model/dataGrid';

fixture.disablePageReloads`Focus`
.page(url(__dirname, '../../container.html'));

const GRID_SELECTOR = '#container';
const FOCUSED_CLASS = 'dx-focused';

test('Should remove dx-focused class on blur event from the cell', async (t) => {
const dataGrid = new DataGrid(GRID_SELECTOR);

const firstCell = dataGrid.getDataCell(0, 1);
const secondCell = dataGrid.getDataCell(1, 1);

await t
.click(firstCell.element)
.click(secondCell.element);

await t.expect(firstCell.element().hasClass(FOCUSED_CLASS)).notOk();
await t.expect(secondCell.element().hasClass(FOCUSED_CLASS)).ok();
}).before(async () => createWidget('dxDataGrid', {
dataSource: [
{ A: 0, B: 1, C: 2 },
{ A: 3, B: 4, C: 5 },
{ A: 6, B: 7, C: 8 },
],
editing: {
mode: 'batch',
allowUpdating: true,
startEditAction: 'dblClick',
},
onCellClick: (event) => event.component.focus(event.cellElement),
}));
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import createWidget from '../../../helpers/createWidget';
import url from '../../../helpers/getPageUrl';
import DataGrid from '../../../model/dataGrid';
import { CallbackTestHelper, WindowCallbackExtended } from '../../../helpers/callbackTestHelper';
import createWidget from '../../../../helpers/createWidget';
import url from '../../../../helpers/getPageUrl';
import DataGrid from '../../../../model/dataGrid';
import { CallbackTestHelper, WindowCallbackExtended } from '../../../../helpers/callbackTestHelper';

// TODO: Something wrong with test cleanup with 'disablePageReloads'
// old events from previous test still alive on the next test case run
// So, we should disable it for these tests until this problem exists.
fixture`Focused row - new rows T1162227`
.page(url(__dirname, '../../container.html'));
.page(url(__dirname, '../../../container.html'));

type FocusCellChangingData =
[[prevRowIdx: number, prevColumnIdx: number], [rowIdx: number, columnIdx: number]];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { ClientFunction } from 'testcafe';
import url from '../../helpers/getPageUrl';
import createWidget from '../../helpers/createWidget';
import DataGrid from '../../model/dataGrid';
import url from '../../../../helpers/getPageUrl';
import createWidget from '../../../../helpers/createWidget';
import DataGrid from '../../../../model/dataGrid';

fixture.disablePageReloads`Focused row`
.page(url(__dirname, '../container.html'));
.page(url(__dirname, '../../../container.html'));

test('onFocusedRowChanged event should fire once after changing focusedRowKey if paging.enabled = false (T755722)', async (t) => {
const dataGrid = new DataGrid('#container');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { createScreenshotsComparer } from 'devextreme-screenshot-comparer';
import { changeTheme } from '../../../helpers/changeTheme';
import createWidget from '../../../helpers/createWidget';
import url from '../../../helpers/getPageUrl';
import DataGrid from '../../../model/dataGrid';
import { Themes } from '../helpers/themes';
import { changeTheme } from '../../../../helpers/changeTheme';
import createWidget from '../../../../helpers/createWidget';
import url from '../../../../helpers/getPageUrl';
import DataGrid from '../../../../model/dataGrid';
import { Themes } from '../../helpers/themes';

fixture.disablePageReloads`Focused row - markup`
.page(url(__dirname, '../../container.html'));
.page(url(__dirname, '../../../container.html'));

// TODO: Enable multi-theming testcafe run in the future.
[
Expand Down