Skip to content

Conversation

@GDamyanov
Copy link
Contributor

@GDamyanov GDamyanov commented Nov 19, 2025

This PR introduces support for disabling specific date ranges in the ui5-calendar component via the new disabledDates slot. Applications can now pass one or more ui5-date-range elements to the calendar, specifying startValue and/or endValue to mark dates as non-selectable.

Key Changes

  • Added disabledDates slot to ui5-calendar for passing disabled date ranges.

  • Implemented logic in DayPicker to prevent selection of dates within disabled ranges.

  • Updated internal date parsing to respect the calendar’s formatPattern.

  • Added comprehensive JSDoc documentation for new properties and methods.

  • Created Cypress tests to verify disabled date functionality, including edge cases and format pattern support.

  • Updated sample and test pages to demonstrate usage.

Motivation
This feature allows applications to restrict user selection to valid dates only, improving UX for scenarios like booking, scheduling, or compliance.

@ui5-webcomponents-bot
Copy link
Collaborator

ui5-webcomponents-bot commented Nov 19, 2025

@ui5-webcomponents-bot ui5-webcomponents-bot temporarily deployed to preview November 19, 2025 08:59 Inactive
@ui5-webcomponents-bot ui5-webcomponents-bot temporarily deployed to preview November 19, 2025 09:26 Inactive
@GDamyanov GDamyanov requested a review from Todor-ads November 19, 2025 09:33
@GDamyanov GDamyanov marked this pull request as ready for review November 19, 2025 09:33
@ui5-webcomponents-bot ui5-webcomponents-bot temporarily deployed to preview November 19, 2025 09:40 Inactive
@GDamyanov GDamyanov changed the title feat(ui5-calendar): define disabled dates feat(ui5-calendar): add disabled dates functionality Nov 19, 2025
@GDamyanov GDamyanov self-assigned this Nov 19, 2025
@GDamyanov GDamyanov requested a review from Stoev November 19, 2025 09:42
@ui5-webcomponents-bot ui5-webcomponents-bot temporarily deployed to preview November 19, 2025 14:49 Inactive
@ui5-webcomponents-bot ui5-webcomponents-bot temporarily deployed to preview November 19, 2025 15:03 Inactive
@GDamyanov GDamyanov requested a review from Stoev November 20, 2025 07:51
@ui5-webcomponents-bot ui5-webcomponents-bot temporarily deployed to preview November 20, 2025 07:53 Inactive
@ui5-webcomponents-bot ui5-webcomponents-bot temporarily deployed to preview November 20, 2025 12:11 Inactive
@ui5-webcomponents-bot ui5-webcomponents-bot temporarily deployed to preview November 21, 2025 07:46 Inactive
@ui5-webcomponents-bot ui5-webcomponents-bot temporarily deployed to preview November 24, 2025 07:56 Inactive
@ui5-webcomponents-bot ui5-webcomponents-bot temporarily deployed to preview November 24, 2025 19:44 Inactive
@ui5-webcomponents-bot ui5-webcomponents-bot temporarily deployed to preview November 25, 2025 09:01 Inactive
@ui5-webcomponents-bot ui5-webcomponents-bot temporarily deployed to preview November 25, 2025 10:28 Inactive
@ui5-webcomponents-bot ui5-webcomponents-bot temporarily deployed to preview November 25, 2025 13:29 Inactive
* A date is considered disabled if:
* - It falls outside the min/max date range defined by the component
* - It matches a single disabled date
* - It falls within a disabled date range (inclusive of start and end dates)
Copy link

Choose a reason for hiding this comment

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

Please double-check the validity of this Copilot suggestion:

Bulleted list states ranges are "inclusive of start and end dates", while the implementation uses exclusive comparisons (">" and "<") when both start and end are present. If you intend inclusivity, update the code to use >= / <= to match the original wording.

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 555c611

@GDamyanov GDamyanov requested a review from Stoev November 25, 2025 14:50
@ui5-webcomponents-bot ui5-webcomponents-bot temporarily deployed to preview November 25, 2025 14:54 Inactive
.realClick();

// Verify the date was not selected
cy.get<Calendar>("#calendar1")
Copy link
Contributor

Choose a reason for hiding this comment

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

why don't we just check if the day that we are clicking on does not have specific class, but we need to invoke a property and check there?

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 5decd79

.realClick();

// The disabled date should not be selectable
cy.get<Calendar>("#calendar1")
Copy link
Contributor

Choose a reason for hiding this comment

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

same as prev comment

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 5decd79

return this.getSlottedNodes<SpecialCalendarDate>("specialDates");
}

get _disabledDateRanges() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can't we get this with just this.disabledDates?

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 9d30dc5

Comment on lines 847 to 858
const startTimestamp = this._getTimestampFromDateValue(range.startValue);
const endTimestamp = this._getTimestampFromDateValue(range.endValue);

if (endTimestamp) {
return dateTimestamp > startTimestamp && dateTimestamp < endTimestamp;
}

if (startTimestamp && !endTimestamp) {
return dateTimestamp === startTimestamp;
}

return false;
Copy link
Contributor

Choose a reason for hiding this comment

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

This can be optimised to:

if (endTimestamp) {
return dateTimestamp > startTimestamp && dateTimestamp < endTimestamp;
}
return startTimestamp && dateTimestamp === startTimestamp;

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 e601fb8

return 0;
}

try {
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we sure that either of the methods throw an error to be caught?

If not we can just go for:

const jsDate = this.getValueFormat().parse(dateValue);
const calendarDate = CalendarDate.fromLocalJSDate(
jsDate,
this._primaryCalendarType,
);
return calendarDate.valueOf() / 1000;

And if needed to check if there's calendarDate before returning it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fromLocalJSDate method throws exception.

@ui5-webcomponents-bot ui5-webcomponents-bot temporarily deployed to preview November 26, 2025 16:06 Inactive
@ui5-webcomponents-bot ui5-webcomponents-bot temporarily deployed to preview November 26, 2025 16:16 Inactive
@ui5-webcomponents-bot ui5-webcomponents-bot temporarily deployed to preview November 26, 2025 16:24 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.

6 participants