fooloomanzoo / datetime-picker

A minimal picker for date and time for Polymer, that can use the native input
MIT License
78 stars 18 forks source link

Errors on Handling range of dates #31

Closed on4life closed 6 years ago

on4life commented 6 years ago

Hi, I tried to use range of dates picker but something want wrong. Could you please check this problem?

http://take.ms/qybt7

It happened when I choose "end day" less than "start day"

<date-picker class="begin" month="1" day="1" auto-confirm date="{{min}}" max="{{max}}" vertical-align="bottom"></date-picker>
<date-picker class="end" month="12" day="31" auto-confirm date="{{max}}" min="{{min}}" vertical-align="top"></date-picker>
fooloomanzoo commented 6 years ago

And what would you expect to happen, if you choose an earlier date for maximum than the minimum? The elements try to set then the values to their margins. Because you have two separated elements there is no way to mediate for them, if you don't include another binding. But if min and max are set for an element then it would turn around min and max if they are in a wrong order. This problem you are getting is only occurring because of your attempt to preset the date. I would suggest that you include another hidden date-input as a mediator and bind its min and max attributes to the attributes of your pickers.

fooloomanzoo commented 6 years ago
    <date-picker auto-confirm month="12" day="31" date="{{min}}" max="[[max]]"></date-picker>
    <date-picker auto-confirm month="1" day="1" date="{{max}}" min="[[min]]"></date-picker>
    <date-input hidden max="{{max}}" min="{{min}}"></date-input>