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

Calendar: re-adjust constants for _firstDateInView calculation (T1253076) #28423

Open
wants to merge 2 commits into
base: 24_2
Choose a base branch
from
Open
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 @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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 = {
Expand Down Expand Up @@ -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), 'cell is highlighted');
});

['startDateBox', 'endDateBox'].forEach((dateBoxName) => {
QUnit.test(`${dateBoxName} should update value on DateRangeBox value change`, function(assert) {
const newValue = ['2023/04/18', '2023/05/03'];
Expand Down
Loading