Skip to content

feat(ui5-daterange-picker): two months mode is implemented#13196

Open
GDamyanov wants to merge 45 commits intomainfrom
twocalendars
Open

feat(ui5-daterange-picker): two months mode is implemented#13196
GDamyanov wants to merge 45 commits intomainfrom
twocalendars

Conversation

@GDamyanov
Copy link
Contributor

@GDamyanov GDamyanov commented Mar 5, 2026

This PR adds a new showTwoCalendars property to the DateRangePicker component that displays two consecutive months side by side, making it easier to select date ranges that span multiple months.

New Property - showTwoMonths (boolean, default: false)

  • When enabled, the calendar popup displays two consecutive months instead of one
  • Automatically adapts to mobile devices, showing a single calendar on phones
  • Works seamlessly with existing date range selectiond)

@ui5-webcomponents-bot
Copy link
Collaborator

ui5-webcomponents-bot commented Mar 5, 2026

@ui5-webcomponents-bot ui5-webcomponents-bot temporarily deployed to preview March 5, 2026 11:56 Inactive
@ui5-webcomponents-bot ui5-webcomponents-bot temporarily deployed to preview March 5, 2026 13:23 Inactive
@ui5-webcomponents-bot ui5-webcomponents-bot temporarily deployed to preview March 5, 2026 14:56 Inactive
@ui5-webcomponents-bot ui5-webcomponents-bot temporarily deployed to preview March 6, 2026 09:24 Inactive
@ui5-webcomponents-bot ui5-webcomponents-bot temporarily deployed to preview March 6, 2026 09:36 Inactive
@ui5-webcomponents-bot ui5-webcomponents-bot temporarily deployed to preview March 6, 2026 13:43 Inactive
@ui5-webcomponents-bot ui5-webcomponents-bot temporarily deployed to preview March 9, 2026 08:25 Inactive
@ui5-webcomponents-bot ui5-webcomponents-bot temporarily deployed to preview March 9, 2026 09:15 Inactive
@ui5-webcomponents-bot ui5-webcomponents-bot temporarily deployed to preview March 10, 2026 07:55 Inactive
@ui5-webcomponents-bot ui5-webcomponents-bot temporarily deployed to preview March 12, 2026 13:39 Inactive
@ui5-webcomponents-bot ui5-webcomponents-bot temporarily deployed to preview March 13, 2026 08:47 Inactive
@ui5-webcomponents-bot ui5-webcomponents-bot temporarily deployed to preview March 13, 2026 09:20 Inactive
@ui5-webcomponents-bot ui5-webcomponents-bot temporarily deployed to preview March 13, 2026 09:27 Inactive
@ui5-webcomponents-bot ui5-webcomponents-bot temporarily deployed to preview March 13, 2026 09:55 Inactive
@GDamyanov GDamyanov changed the title feat(ui5-daterange-picker): two calendars feat(ui5-daterange-picker): two months mode is implemented Mar 13, 2026
@GDamyanov GDamyanov marked this pull request as ready for review March 13, 2026 10:02
@GDamyanov GDamyanov requested a review from hinzzx March 13, 2026 10:03
@ui5-webcomponents-bot ui5-webcomponents-bot temporarily deployed to preview March 13, 2026 10:07 Inactive
@ui5-webcomponents-bot ui5-webcomponents-bot temporarily deployed to preview March 16, 2026 08:00 Inactive
@ui5-webcomponents-bot ui5-webcomponents-bot temporarily deployed to preview March 17, 2026 11:34 Inactive
<>
{/* When pickers are active, show standard calendar header */}
{this._shouldShowOnePickerHeaderButtonInMultipleMonths && (
<div class="ui5-calheader ui5-calheader-multiple ui5-calheader-default-multiple test" exportparts="calendar-header-arrow-button, calendar-header-middle-button">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missed 'test' class

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 3adc903

Comment on lines +282 to +283
*/
_submitClick() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The OK/Cancel footer is rendered on phone, but onSelectedDatesChange (inherited from DatePicker) auto-closes the picker when 2 dates are selected via _togglePicker(). So:

  1. User selects first date → picker stays open
  2. User selects second date → picker auto-closes immediately
  3. OK/Cancel buttons are never reachable

This makes _submitClick, _cancelClick, _submitDisabled, _okButtonText, _cancelButtonText, and the two new i18n keys all effectively dead code.

Fix: Modify onSelectedDatesChange to NOT auto-close when showTwoMonths && isPhone()

return `${DateRangePicker.i18nBundle.getText(DATETIME_COMPONENTS_PLACEHOLDER_PREFIX)} ${this._lastDateRangeForTheCurrentYear}`;
}

get _submitDisabled() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This allows OK button to be enabled with only 1 date, as this component is supposed to be a range pick, I think it would be reasonable to do:

return !this._calendarSelectedDates || this._calendarSelectedDates.length < 2;

return;
}

const newValue = this._buildValue(this._startDateTimestamp, this._endDateTimestamp);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this line reads from this.value, not from the calendar's current selection

we could extract timestamps from the calendar's _calendarSelectedDates

@property({ type: Boolean })
stretch = false;

/**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missed JSDoc, please remove it

font-weight: bold;
}

.ui5-daterange-calendar-mobile-footer {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this class is not used anywhere

pointer-events: all;
background: var(--sapGroup_ContentBackground);
border-radius: var(--_ui5_popup_border_radius);
min-height: 2rem;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dont we need a variable here and at line 135 to handle compact/cozy scenacrios ?

}

.ui5-cal-month-header-container {
width: 50%;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this only assumes exactly two months, can we use flex: 1 for flexibility ?

}); No newline at end of file
});

describe("DateRangePicker - Two Calendars Feature", () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have few missing test cases, for example:

  • We have implemented a lot of phone features, we should test some cases. You can use cy.ui5SimulateDevice("phone").
  • Mobile footer OK/Cancel buttons
  • Min/Max date constraints with two months
  • Dynamic toggle of showTwoMonths after initial render

@@ -1,5 +1,6 @@
.ui5-date-picker-popover {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With most of the secondary-calendar types, there is slight misalignment.

Image

@ui5-webcomponents-bot ui5-webcomponents-bot temporarily deployed to preview March 18, 2026 07:37 Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants