jcsmorais / shortcut-buttons-flatpickr

Flatpickr's plugin that provides users an alternative way to interact with the datetime picker.
MIT License
26 stars 15 forks source link

Error when mobile #9

Open projct1 opened 5 years ago

projct1 commented 5 years ago

Hio) http://skrinshoter.ru/s/080619/aQdkvR03 Flatpickr using native mobile picker. I guess problem is with this.

jcsmorais commented 5 years ago

@projct1 thanks for your issue report 👍

Which versions are you using for both, flatpickr and shortcut-buttons-flatpickr? Can you provide a jsfiddle/codepen example so that I can easily reproduce the behavior you're reporting?

Thanks

projct1 commented 5 years ago

@jcsmorais plugin is 0.3.0, flatpickr is 4.5.7 I cant create fiddle :( Below my code and initialization.

require('flatpickr').localize(require('flatpickr/dist/l10n/ru').default.ru);

flatpickr.setDefaults({
    plugins: [
        require('shortcut-buttons-flatpickr')({
            button: [
                {label: 'Сегодня'},
                {label: 'Завтра'},
                {label: 'Послезавтра'}
            ],
            onClick(index, fp) {
                let date = index ? new Date(Date.now() + 24 * index * 60 * 60 * 1000) : new Date;

                fp.setDate(date, true);
                fp.close();
            }
        })
    ]
});

$('[name=date]').flatpickr();
jcsmorais commented 5 years ago

@projct1 based on your information I created this codepen where I was able to reproduce the issue.

This is actually the first time I'm testing flatpickr on mobile, according to the documentation if a mobile devices is detected it falls back to native date/time/datetime picker.

So a quick fix would be to just disable shortcut-buttons-flatpickr plugin once a mobile device is detected.

A long term fix would be to make it work on mobile devices the same way it does for web apps.

Let me know if you have any thoughts around that.

projct1 commented 5 years ago

@jcsmorais Thanks) Can you add check, if flatpickr instance is array after init http://skrinshoter.ru/s/090619/y0pnhC0u => http://skrinshoter.ru/s/090619/wm7tNWyH then disable? :)

jcsmorais commented 5 years ago

@projct1 sorry for the late reply. I definitely can, just ran out of time to do so in the last few weeks - should be able to get that done sometime soon.