Skip to content
This repository has been archived by the owner on Jul 16, 2022. It is now read-only.

Date cycle got no date option when input is empty #174

Open
vorkristof opened this issue Jul 3, 2017 · 1 comment
Open

Date cycle got no date option when input is empty #174

vorkristof opened this issue Jul 3, 2017 · 1 comment
Labels

Comments

@vorkristof
Copy link

This problem appeared when I used PickMeUp for holiday picking where I needed the input field to be empty.
I used it in my js file like this:

pickmeup('.pickmeup-date input', {
    position       : 'bottom',
    hide_on_select : false,
    format: 'Y-m-d',
    mode : 'multiple',
    separator: ', ',
    default_date: false,
    date: []
});

So when the date is an empty array it will appear in the site without any starting date in the input field.
But there was a bug when I went throuh the day-month-year cycle, it got NaN values for the years and days.
I found out that it is not checked in the code where the new date is set.

if (options.mode != 'single') {
    options.current = new Date(options.date[options.date.length - 1]);
}

I fixed the problem with a simple check of the value of the target, so it won't try to set a new date without any reference from the input.

if (options.mode != 'single') {
    if (target.value !== '') {
        options.current = new Date(options.date[options.date.length - 1]);
    }
}
@nazar-pc
Copy link
Owner

nazar-pc commented Jul 3, 2017

Thanks for reporting this! Confirmed with this demo: https://jsfiddle.net/yyhcncgt/

@nazar-pc nazar-pc added the bug label Jul 3, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants