question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

DatePicker::setMaxDate(<date_in_past>) -> calendar view jumps to Jan 0001

See original GitHub issue

Reproducible 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:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
DMihaylovacommented, Feb 11, 2019

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

1reaction
krodyrobicommented, Jan 28, 2019

@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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found