Skip to content

Commit da081ca

Browse files
authored
Scheduler: T1187849 — Fix multi-cell selection on touch monitors (DevExpress#33458)
1 parent a0e0e4d commit da081ca

3 files changed

Lines changed: 24 additions & 28 deletions

File tree

packages/devextreme/js/__internal/scheduler/__tests__/selection_end_event.test.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
} from '@jest/globals';
44
import type { SelectionEndEvent } from '@js/ui/scheduler';
55
import { fireEvent } from '@testing-library/dom';
6+
import support from '@ts/core/utils/m_support';
67

78
import fx from '../../../common/core/animation/fx';
89
import { createScheduler } from './__mock__/create_scheduler';
@@ -65,6 +66,27 @@ describe('onSelectionEnd', () => {
6566
expect(component).toBe(scheduler);
6667
});
6768

69+
it('T1187849: should select cells with mouse on touch monitor', async () => {
70+
const originalSupportTouch = support.touch;
71+
support.touch = true;
72+
73+
const { POM, scheduler } = await createScheduler(defaultOptions);
74+
const firstCell = POM.getDateTableCell(0, 0);
75+
const secondCell = POM.getDateTableCell(1, 0);
76+
77+
expect(scheduler.getWorkSpace().getScrollable().option('scrollByContent')).toBe(true);
78+
79+
fireEvent.mouseDown(firstCell, { which: 1 });
80+
fireEvent.mouseMove(secondCell, { which: 1 });
81+
fireEvent.mouseUp(secondCell, { which: 1 });
82+
83+
expect(scheduler.option('selectedCellData')).toHaveLength(2);
84+
expect(firstCell.classList.contains('dx-state-focused')).toBe(true);
85+
expect(secondCell.classList.contains('dx-state-focused')).toBe(true);
86+
87+
support.touch = originalSupportTouch;
88+
});
89+
6890
it('should not fire onSelectionEnd when clicking on an already-selected cell', async () => {
6991
const onSelectionEnd = jest.fn<(e: SelectionEndEvent) => void>();
7092

packages/devextreme/js/__internal/scheduler/workspaces/m_work_space.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1250,7 +1250,7 @@ class SchedulerWorkSpace extends Widget<WorkspaceOptionsInternal> {
12501250
(eventsEngine.off as any)(element, SCHEDULER_CELL_DXPOINTERDOWN_EVENT_NAME);
12511251

12521252
eventsEngine.on(element, SCHEDULER_CELL_DXPOINTERDOWN_EVENT_NAME, DRAG_AND_DROP_SELECTOR, (e) => {
1253-
if (isMouseEvent(e) && e.which === 1) {
1253+
if ((isMouseEvent(e) || (e.originalEvent && isMouseEvent(e.originalEvent))) && e.which === 1) {
12541254
isPointerDown = true;
12551255
(this.$element() as any).addClass(WORKSPACE_WITH_MOUSE_SELECTION_CLASS);
12561256
(eventsEngine.off as any)(domAdapter.getDocument(), SCHEDULER_CELL_DXPOINTERUP_EVENT_NAME);
@@ -1262,7 +1262,7 @@ class SchedulerWorkSpace extends Widget<WorkspaceOptionsInternal> {
12621262
});
12631263

12641264
eventsEngine.on(element, SCHEDULER_CELL_DXPOINTERMOVE_EVENT_NAME, DRAG_AND_DROP_SELECTOR, (e) => {
1265-
if (isPointerDown && this._dateTableScrollable && !this._dateTableScrollable.option('scrollByContent')) {
1265+
if (isPointerDown && this._dateTableScrollable) {
12661266
e.preventDefault();
12671267
e.stopPropagation();
12681268
this.moveToCell($(e.target), true);

packages/devextreme/testing/tests/DevExpress.ui.widgets.scheduler/workSpace.navigation.tests.js

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -779,32 +779,6 @@ module('Workspace navigation', () => {
779779
assert.equal(cells.filter('.dx-state-focused').length, 1, 'right quantity of focused cells');
780780
});
781781

782-
test('It should not be possible to select cells via mouse if scrollable \'scrollByContent\' is true', async function(assert) {
783-
const $element = this.createInstance({
784-
focusStateEnabled: true,
785-
firstDayOfWeek: 1,
786-
currentDate: new Date(2015, 3, 1),
787-
height: 400,
788-
allowMultipleCellSelection: true,
789-
onContentReady: function(e) {
790-
const scrollable = e.component._dateTableScrollable;
791-
scrollable.option('scrollByContent', true);
792-
},
793-
}, 'dxSchedulerWorkSpaceMonth');
794-
const workspace = $element.dxSchedulerWorkSpaceMonth('instance');
795-
796-
const stub = sinon.stub(workspace, 'notifyObserver');
797-
798-
const cells = $element.find('.' + CELL_CLASS);
799-
const cell = cells.eq(23).get(0);
800-
const $table = $element.find('.dx-scheduler-date-table');
801-
802-
pointerMock(cells.eq(2)).start().click();
803-
$($table).trigger($.Event('dxpointermove', { target: cell, toElement: cell, which: 1 }));
804-
805-
assert.notOk(stub.calledOnce, 'Cells weren\'t selected');
806-
});
807-
808782
test('Multiselection with left arrow should work in workspace day', async function(assert) {
809783
const $element = this.createInstance({
810784
focusStateEnabled: true,

0 commit comments

Comments
 (0)