Hello everyone, I'm facing an issue and would love to have your help:
Actual Behavior:
ng-model
to currently new Date()
then clicking on the datepicker to show the calendar, the calendar does not position itself automatically to the current date, but to the beginning of the date rangeContext:
Code:
md-datepicker(name="dateField" ng-model="myDate")
Angular Versions:
Additional Information:
Thank you for your help !
Can you post a minimal demo that shows the issue? Otherwise it's hard to pinpoint it.
+1 I have same issue
Yep= ( and I have same issue
Currently, it seems to scroll to the month after the one which is currently selected, or at least that's what I'm seeing.
When squeeze height, datepicker is not scroll automaticaly to selected date
@aider Thanks for the demo. Can definitely reproduce. I had to shrink my window to make it short enough, but I definitely see it.
I believe that problem is related to these two methods in Datepicker.js module:
CalendarCtrl.prototype.setCurrentView = function(newView, time) ...
CalendarCtrl.prototype.focus = function(date) ...
Apparently, they are used to focus the selected date in Calendar using the field displayDate, but there's not the same code for DatePicker. Using Calendar the date selected is focused without no problem.
@alanssoares Checked both the methods. I found out the issue occurred inside the below method of CalendarMonthBodyCtrl.
CalendarMonthBodyCtrl.prototype.generateContent =function() {
..
}
Commenting the below line fixed the issue for me:
//this.focusAfterAppend.focus();
@amoljv it works :)
Thanks a lot !
facing same issue @amoljv solution works. please thing to merge it.
@amoljv thanks for this! Was pulling out my hair trying to find a solution.
https://github.com/angular/material/pull/11054 was submitted to fix this but it was not targeted at the master
branch, it didn't follow the commit guidelines, and it has extra commits included in the PR that were not relevant.
It would be great if someone could submit a new PR that addresses these issues and deletes the line instead of commenting it out.
Actually, I just updated the Plunker to AngularJS Material 1.1.5 and this issue appears to have been fixed already. I can reproduce the issue with 1.1.1, but not with 1.1.5.
If you can reproduce this on 1.1.5 or HEAD, please create a new issue with a CodePen or Plunker that demonstrates the issue.
Most helpful comment
@alanssoares Checked both the methods. I found out the issue occurred inside the below method of CalendarMonthBodyCtrl.
Commenting the below line fixed the issue for me: