Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

minDate is ignored/not working in inline datepicker #5672

Closed
SlippySken opened this issue Mar 22, 2016 · 5 comments
Closed

minDate is ignored/not working in inline datepicker #5672

SlippySken opened this issue Mar 22, 2016 · 5 comments

Comments

@SlippySken
Copy link

I don't know if it's a bug or it's by design. But in the inline datepicker, if a mindate is passed per datepicker-options, the value is ignored. In the datepicker popup, everything works fine. You can reproduce that behaviour on the sample page. I copied it and produced a plunkr.
http://plnkr.co/edit/lMKk9yYkD41QgQvrXbwQ?p=preview

Angular: 1.5.0

UIBS: 1.2.5

Bootstrap: 3.3.6

Browser: latest Firefox

@SlippySken
Copy link
Author

If you configure a min date in the config section of angular, then the minDate in the inline datepicker works. But this is no valid workaround for me, because i can't configure the minDate at the start of my webapp.
I added this to the plunkr.
angular.module('ui.bootstrap.demo').config(['uibDatepickerConfig', function (datepickerConfig) { datepickerConfig.minDate = new Date(2016, 0, 1); }]);

@wesleycho
Copy link
Contributor

This works - the toggleMin function in the Plunker posted had a bug, as seen here

@SlippySken
Copy link
Author

@wesleycho : But now you can't switch back. The toggle functionality is broken now. I think the minDate property of the inline datepicker isn't watched and updated.
I created a new plunkr with an other function, where you can set the minDate to the 10th of march 2016 (press the "Set min date"-Button).

Before you press the button, the minDate of both datepickers is the first day of the year. After pressing the button, the minDate of the popover datepicker is refreshed, but the inline datepicker is not.

Please have a look http://plnkr.co/edit/KysM1SZ3kQkcSacrJmcR?p=preview

@wesleycho
Copy link
Contributor

Ah, I think I know what is happening - if it does not have a truthy initial value, it will not set a watcher, and thus will not see the change from the toggle.

This is a subtle bug - I will fix this after #5676 is merged, should be an easy fix.

@wesleycho
Copy link
Contributor

I think this was done by design when thinking about it to reduce watchers, but I think this is a minor optimization in this case and am ok with changing the behavior here.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants