DatePicker::setMaxDate(<date_in_past>) -> calendar view jumps to Jan 0001
See original GitHub issueReproducible in: Chrome, Firefox, IE UI5 version: 1.61.1
STR: Select in second datepicker current date: example today is 21 Jan so I select 21 Jan Open first datepicker
Expected: See current month with up to Jan 20 as possible values
Actual: See Jan 0001 as calendar header / values Max date is set to correct value.
Notes: Doesn’t matter if I have a value selected in the first picker or not. Doesn’t matter if I use methods on the datepicker or modify the model and refresh.
<mvc:View controllerName="date-str.date-str.controller.Main" xmlns:html="http://www.w3.org/1999/xhtml" xmlns:mvc="sap.ui.core.mvc"
displayBlock="true" xmlns="sap.m">
<App id="idAppControl">
<pages>
<Page title="{i18n>title}">
<content>
<DatePicker id="start"></DatePicker>
<DatePicker id="end" change="onChange"></DatePicker>
</content>
</Page>
</pages>
</App>
</mvc:View>
sap.ui.define([
"sap/ui/core/mvc/Controller"
], function (Controller) {
"use strict";
return Controller.extend("date-str.date-str.controller.Main", {
onInit: function () {
var view = this.getView();
this.start = view.byId("start");
this.end = view.byId("end");
},
onChange: function(event) {
var selectedDate = event.getSource().getDateValue();
var clonedDate = new Date(selectedDate);
var dateOneDayInPast = new Date(clonedDate.setDate(clonedDate.getDate() - 1));
this.start.setMaxDate(dateOneDayInPast);
}
});
});
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:5 (1 by maintainers)
Top Results From Across the Web
View your day, week, or month - Google Calendar Help
Tap a date to see events on that day. Get back to today: At the top right corner, tap Jump to today Event...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @krodyrobi,
You could define the initially focused date through the DateTimeField’s initialFocusedDateValue property. After setting the maxDate in your change handler, you could do something like this: this.start.setInitialFocusedDateValue(dateOneDayInPast);
API: https://openui5.hana.ondemand.com/#/api/sap.m.DateTimeField/controlProperties/
Therefore I’m closing the issue.
Thanks & Regards, Diana
@stephania87
When I set the min, max dates to a calendar I’d expect it to grey out dates outside this range, not change the displayed month. The displayed month should either be the current month or a previously viewed month but definitely not the edges of the range in case of one of them is missing.
(-inf, today), (today, +inf) are valid ranges. Why should I be required to fill both, it can default to Jan 0001 but it should not jump to show me that date. I’m not talking about the calendar view but the higher level of abstraction DatePicker.