Skip to content

Commit 8c66d5a

Browse files
authoredMay 14, 2021
fix(ui5-calendar): correct enable/disable of prev and next buttons (#3249)
Prev and next buttons should be disabled when there is min and max dates set Fixes #3201
1 parent eba1e64 commit 8c66d5a

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed
 

‎packages/main/src/CalendarHeader.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -138,11 +138,11 @@ class CalendarHeader extends UI5Element {
138138
return {
139139
prevButton: {
140140
"ui5-calheader-arrowbtn": true,
141-
"ui5-calheader-arrowbtn-disabled": this._isPrevButtonDisabled,
141+
"ui5-calheader-arrowbtn-disabled": this.isPrevButtonDisabled,
142142
},
143143
nextButton: {
144144
"ui5-calheader-arrowbtn": true,
145-
"ui5-calheader-arrowbtn-disabled": this._isNextButtonDisabled,
145+
"ui5-calheader-arrowbtn-disabled": this.isNextButtonDisabled,
146146
},
147147
};
148148
}

‎packages/main/test/pages/Calendar.html

+5
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@
6464
</ui5-calendar>
6565
</section>
6666

67+
<section>
68+
<ui5-title>Calendar with Minimum and Maximum Date & Format Pattern</ui5-title>
69+
<ui5-calendar id="calendar4" data-ui5-compact-size min-date="7/7/2020" max-date="20/10/2020" timestamp="1594080000" format-pattern="dd/MM/yyyy"></ui5-calendar>
70+
</section>
71+
6772
</body>
6873

6974
<script>

‎packages/main/test/specs/Calendar.spec.js

+22
Original file line numberDiff line numberDiff line change
@@ -250,4 +250,26 @@ describe("Calendar general interaction", () => {
250250

251251
assert.deepEqual(selectedDates, [971740800, 971913600], "Change event is fired with proper data");
252252
});
253+
254+
it("Previous and next buttons are disabled when necessary", () => {
255+
browser.url(`http://localhost:${PORT}/test-resources/pages/Calendar.html`);
256+
const calendarHeader = browser.$("#calendar4").shadow$("ui5-calendar-header");
257+
const prevButton = calendarHeader.shadow$(`[data-ui5-cal-header-btn-prev]`);
258+
const nextButton = calendarHeader.shadow$(`[data-ui5-cal-header-btn-next]`);
259+
260+
assert.ok(prevButton.hasClass("ui5-calheader-arrowbtn-disabled"), "Previous Button is disabled");
261+
assert.notOk(nextButton.hasClass("ui5-calheader-arrowbtn-disabled"), "Next Button is enabled");
262+
263+
nextButton.click();
264+
265+
assert.notOk(prevButton.hasClass("ui5-calheader-arrowbtn-disabled"), "Previous Button is enabled");
266+
assert.notOk(nextButton.hasClass("ui5-calheader-arrowbtn-disabled"), "Next Button is enabled");
267+
268+
nextButton.click();
269+
nextButton.click();
270+
271+
assert.notOk(prevButton.hasClass("ui5-calheader-arrowbtn-disabled"), "Previous Button is enabled");
272+
assert.ok(nextButton.hasClass("ui5-calheader-arrowbtn-disabled"), "Next Button is disabled");
273+
});
274+
253275
});

0 commit comments

Comments
 (0)
Please sign in to comment.