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

fix(ui5-date-picker): fixed samples and daypicker limits #2280

Merged
merged 2 commits into from
Oct 1, 2020
Merged
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
8 changes: 7 additions & 1 deletion packages/main/src/DayPicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -800,8 +800,14 @@ class DayPicker extends UI5Element {

_isOutOfSelectableRange(date) {
const currentDate = date._oUDate ? date.toLocalJSDate() : CalendarDate.fromTimestamp(date).toLocalJSDate();
const minDate = this._minDateObject;
const maxDate = this._maxDateObject;

return currentDate > this._maxDateObject || currentDate < this._minDateObject;
currentDate.setHours(0);
minDate.setHours(0);
maxDate.setHours(0);

return currentDate > maxDate || currentDate < minDate;
}

get _maxDate() {
Expand Down
2 changes: 1 addition & 1 deletion packages/main/test/pages/DatePicker.html
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ <h3>2 months range</h3>
<h3>3 months range</h3>
<ui5-date-picker id="minMax3" value="5/6/2020" min-date="6/1/2020" max-date="5/1/2021" format-pattern="dd/MM/yyyy"></ui5-date-picker>
<h3>1 year range</h3>
<ui5-date-picker id="minMax4" value="5 Feb 2021" min-date="5 Jan 2020" max-date="5 Jan 2021"></ui5-date-picker>
<ui5-date-picker id="minMax4" value="Feb 5, 2020" min-date="Jan 5, 2020" max-date="Jan 5, 2021"></ui5-date-picker>

<section>
<h3>Test ariaLabel and ariaLabelledBy</h3>
Expand Down
10 changes: 10 additions & 0 deletions packages/main/test/specs/DatePicker.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,16 @@ describe("Date Picker Tests", () => {
assert.ok(datepicker.getDisplayedDay(14).isFocusedDeep(), "Days out of range are disabled");
});

it("Min and Max date are included in the interval", () => {
datepicker.id = "#dp33";

datepicker.root.keys("Escape");
datepicker.openPicker({ focusInput: false });

assert.equal(datepicker.getDisplayedDay(9).hasClass("ui5-dp-item--disabled"), false , "Min date is included");
assert.equal(datepicker.getDisplayedDay(11).hasClass("ui5-dp-item--disabled"), false, "Max date is included");
});

it("Tests week numbers column visibility", () => {
// act
datepicker.id = "#dp18";
Expand Down