From 1bc1486d914976257b43612e7898330d70f9a499 Mon Sep 17 00:00:00 2001 From: Nikki Gonzales <38495263+nikkithelegendarypokemonster@users.noreply.github.com> Date: Mon, 25 Nov 2024 02:12:37 +0800 Subject: [PATCH 1/2] Initial Commit --- .../m_calendar.range.selection.strategy.ts | 2 +- .../dateRangeBox.tests.js | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/packages/devextreme/js/__internal/ui/calendar/m_calendar.range.selection.strategy.ts b/packages/devextreme/js/__internal/ui/calendar/m_calendar.range.selection.strategy.ts index b863141abbf8..452b4d7c3b3d 100644 --- a/packages/devextreme/js/__internal/ui/calendar/m_calendar.range.selection.strategy.ts +++ b/packages/devextreme/js/__internal/ui/calendar/m_calendar.range.selection.strategy.ts @@ -117,7 +117,7 @@ class CalendarRangeSelectionStrategy extends CalendarSelectionStrategy { const { currentDate, viewsCount } = this.calendar.option(); const isAdditionalViewDate = this.calendar._isAdditionalViewDate(currentDate); - const firstDateInViews = dateUtils.getFirstMonthDate(dateUtils.addDateInterval(currentDate, 'month', isAdditionalViewDate ? -2 : -1)); + const firstDateInViews = dateUtils.getFirstMonthDate(dateUtils.addDateInterval(currentDate, 'month', isAdditionalViewDate ? -3 : -2)); const lastDateInViews = dateUtils.getLastMonthDate(dateUtils.addDateInterval(currentDate, 'month', isAdditionalViewDate ? 1 : viewsCount)); // @ts-expect-error diff --git a/packages/devextreme/testing/tests/DevExpress.ui.widgets.editors/dateRangeBox.tests.js b/packages/devextreme/testing/tests/DevExpress.ui.widgets.editors/dateRangeBox.tests.js index 0bcf4db7663d..ee438bf180a6 100644 --- a/packages/devextreme/testing/tests/DevExpress.ui.widgets.editors/dateRangeBox.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.ui.widgets.editors/dateRangeBox.tests.js @@ -40,6 +40,7 @@ const CALENDAR_CELL_CLASS = 'dx-calendar-cell'; const CALENDAR_CONTOURED_CELL_CLASS = 'dx-calendar-contoured-date'; const APPLY_BUTTON_SELECTOR = '.dx-popup-done.dx-button'; const CANCEL_BUTTON_SELECTOR = '.dx-popup-cancel.dx-button'; +const CALENDAR_CELL_IN_RANGE_CLASS = 'dx-calendar-cell-in-range'; const CALENDAR_NAVIGATOR_PREVIOUS_VIEW_CLASS = 'dx-calendar-navigator-previous-view'; const BUTTON_SELECTOR = '.dx-button'; const TEXTBOX_SELECTOR = '.dx-textbox'; @@ -52,6 +53,7 @@ const getButtonsContainers = $element => $element.find(`> .${DROP_DOWN_EDITOR_BU const getButtons = $element => $element.find(`.${DROP_DOWN_EDITOR_BUTTON_CLASS}`); const getClearButton = $element => getButtonsContainers($element).find(`.${CLEAR_BUTTON}`); const getPopup = dateBox => dateBox._popup; +const getCurrentViewInstance = (calendar) => calendar._view; const moduleConfig = { @@ -1002,6 +1004,24 @@ QUnit.module('Behavior', moduleConfig, () => { assert.strictEqual(startDateBox.option('opened'), true, 'startDateBox is opened'); }); + QUnit.test('Cells in-range should be highlighted when pressing previous button in calendar (T1253076)', function(assert) { + this.reinit({ + value: ['2025-01-01', '2025-12-31'], + min: new Date('2025-01-01'), + max: new Date('2025-12-31'), + multiView: true + }); + + this.$startDateInput.trigger('click'); + const calendar = this.getCalendar(); + + $(`.${CALENDAR_CELL_CLASS}`).eq(3).trigger('dxclick'); + + const $cell = $(getCurrentViewInstance(calendar).$element().find('*[data-value="2025/11/01"]')); + + assert.ok($cell.hasClass(CALENDAR_CELL_IN_RANGE_CLASS)); + }); + ['startDateBox', 'endDateBox'].forEach((dateBoxName) => { QUnit.test(`${dateBoxName} should update value on DateRangeBox value change`, function(assert) { const newValue = ['2023/04/18', '2023/05/03']; From cc8d2c7c6350b6ca202080615d2c7042ce7778f2 Mon Sep 17 00:00:00 2001 From: Nikki Gonzales <38495263+nikkithelegendarypokemonster@users.noreply.github.com> Date: Mon, 25 Nov 2024 03:00:51 +0800 Subject: [PATCH 2/2] add assert message --- .../tests/DevExpress.ui.widgets.editors/dateRangeBox.tests.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/devextreme/testing/tests/DevExpress.ui.widgets.editors/dateRangeBox.tests.js b/packages/devextreme/testing/tests/DevExpress.ui.widgets.editors/dateRangeBox.tests.js index ee438bf180a6..d367cd459682 100644 --- a/packages/devextreme/testing/tests/DevExpress.ui.widgets.editors/dateRangeBox.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.ui.widgets.editors/dateRangeBox.tests.js @@ -1019,7 +1019,7 @@ QUnit.module('Behavior', moduleConfig, () => { const $cell = $(getCurrentViewInstance(calendar).$element().find('*[data-value="2025/11/01"]')); - assert.ok($cell.hasClass(CALENDAR_CELL_IN_RANGE_CLASS)); + assert.ok($cell.hasClass(CALENDAR_CELL_IN_RANGE_CLASS), 'cell is highlighted'); }); ['startDateBox', 'endDateBox'].forEach((dateBoxName) => {