Skip to content

Commit 2c70828

Browse files
authored
Scheduler - fix scrollTo deprecated API warning when groupValues are not set (#32284)
1 parent 239c4cc commit 2c70828

File tree

3 files changed

+34
-9
lines changed

3 files changed

+34
-9
lines changed

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,29 @@ describe('Scheduler scrollTo deprecation', () => {
3434
expect.stringContaining('W0002'),
3535
);
3636
});
37+
38+
it('should not log deprecation warning when using scrollTo API with date only', async () => {
39+
setupSchedulerTestEnvironment();
40+
const loggerWarnSpy = jest.spyOn(logger, 'warn');
41+
42+
const { scheduler } = await createScheduler({
43+
dataSource: [{
44+
text: 'Meeting',
45+
startDate: new Date(2025, 0, 15, 9, 0),
46+
endDate: new Date(2025, 0, 15, 10, 0),
47+
}],
48+
views: ['week'],
49+
currentView: 'week',
50+
currentDate: new Date(2025, 0, 15),
51+
startDayHour: 8,
52+
endDayHour: 18,
53+
});
54+
loggerWarnSpy.mockReset();
55+
56+
const testDate = new Date(2025, 0, 16, 14, 0);
57+
58+
scheduler.scrollTo(testDate);
59+
60+
expect(loggerWarnSpy).toHaveBeenCalledTimes(0);
61+
});
3762
});

packages/devextreme/js/__internal/scheduler/m_scheduler.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2036,7 +2036,10 @@ class Scheduler extends SchedulerOptionsBaseWidget {
20362036
allDayValue = groupValuesOrOptions.allDay;
20372037
align = groupValuesOrOptions.alignInView ?? 'center';
20382038
} else {
2039-
errors.log('W0002', 'dxScheduler', 'scrollTo', '26.1', 'Use an object with "group", "allDay" and "alignInView" properties instead of separate parameters.');
2039+
if (isDefined(groupValuesOrOptions) || isDefined(allDay)) {
2040+
errors.log('W0002', 'dxScheduler', 'scrollTo', '26.1', 'Use an object with "group", "allDay" and "alignInView" properties instead of separate parameters.');
2041+
}
2042+
20402043
groupValues = groupValuesOrOptions;
20412044
allDayValue = allDay;
20422045
}

packages/devextreme/testing/tests/DevExpress.ui.widgets.scheduler/scrollTo.tests.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -106,16 +106,14 @@ module('ScrollTo', {
106106
scheduler.instance.scrollTo(new Date(2020, 8, 5));
107107
await waitAsync(0);
108108

109-
assert.equal(errors.log.callCount, 2, 'warnings have been called twice');
110-
assert.equal(errors.log.getCall(0).args[0], 'W0002', 'first warning is deprecation warning');
111-
assert.equal(errors.log.getCall(1).args[0], 'W1008', 'second warning has correct error id');
109+
assert.equal(errors.log.callCount, 1, 'warnings have been called once');
110+
assert.equal(errors.log.getCall(0).args[0], 'W1008', 'first warning has correct error id');
112111

113112
scheduler.instance.scrollTo(new Date(2020, 8, 14));
114113
await waitAsync(0);
115114

116-
assert.equal(errors.log.callCount, 4, 'warnings have been called four times total');
117-
assert.equal(errors.log.getCall(2).args[0], 'W0002', 'third warning is deprecation warning');
118-
assert.equal(errors.log.getCall(3).args[0], 'W1008', 'fourth warning has correct error id');
115+
assert.equal(errors.log.callCount, 2, 'warnings have been called two times total');
116+
assert.equal(errors.log.getCall(1).args[0], 'W1008', 'second warning has correct error id');
119117
});
120118

121119
test(`A warning should not be thrown when scrolling to a valid date when ${scrolling.text} is used`, async function(assert) {
@@ -124,8 +122,7 @@ module('ScrollTo', {
124122
scheduler.instance.scrollTo(new Date(2020, 8, 7));
125123
await waitAsync(0);
126124

127-
assert.equal(errors.log.callCount, 1, 'deprecation warning has been called once');
128-
assert.equal(errors.log.getCall(0).args[0], 'W0002', 'warning is deprecation warning for old API');
125+
assert.equal(errors.log.callCount, 0, 'warning has not been called');
129126
});
130127

131128
[{

0 commit comments

Comments
 (0)