bendavis78 / paper-date-picker

Material design date picker component for polymer
http://bendavis78.github.io/paper-date-picker/
MIT License
225 stars 132 forks source link

Min / Max Together Break Calendar #170

Open milleraundra opened 7 years ago

milleraundra commented 7 years ago

When setting the min/max attributes individually, the calendar behaves correctly. When both values are provided, the calendar is blank. See the attached files.

Is there something I'm missing?

screen shot 2017-02-02 at 5 14 32 pm screen shot 2017-02-02 at 5 15 17 pm

ghost commented 7 years ago

The lines causing this (reproducable) bug are the following: If the min-date is greater than the first day of the current month (while at the same time, max-date is in the same month as min-date), the function _withinValidRange() on line #653 will return false, because the validity check function _monthWithinValidRange on line #659 only checks the first and the last of each month if they're within min-date and max-date and doesn't care about the current date being valid, though.

I didn't think of a solution yet, but I hope this helps someone who is able to solve this problem, because I am not that good of a programmer to be able to change this.

While this is not fixed yet, try setting your min-date to the first of the current month at least (which works of course)

minDate: {
    type: Date,
    value: function() {
        var d = new Date();
        return new Date(
            d.getFullYear(), d.getMonth()
        );
    }
}
milleraundra commented 7 years ago

@moritzmenzel Thank you for providing an answer!

My project where I tried to use the component like this was time sensitive, so I had to find a replacement. This does seem to be an important use case that should be worked out though.

admwx7 commented 7 years ago

Is this still an issue for you @milleraundra? If so I'll tag it and prioritize it with everything else for our next release into 2.0 since this is a pretty critical one if it's still around.

milleraundra commented 7 years ago

I am not working with Polymer at this time, so this is not an issue for me anymore. Thanks!

admwx7 commented 7 years ago

Took a look at the logic, it looks like this is still an issue, I'll do a deeper dive on it and see if I can reproduce and address the problem when I get some free time.