shortcut-buttons-flatpickr icon indicating copy to clipboard operation
shortcut-buttons-flatpickr copied to clipboard

Error when mobile

Open projct1 opened this issue 6 years ago • 5 comments

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

projct1 avatar Jun 08 '19 17:06 projct1

@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

jcsmorais avatar Jun 08 '19 17:06 jcsmorais

@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();

projct1 avatar Jun 08 '19 17:06 projct1

@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.

jcsmorais avatar Jun 09 '19 06:06 jcsmorais

@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? :)

projct1 avatar Jun 09 '19 09:06 projct1

@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.

jcsmorais avatar Jul 20 '19 17:07 jcsmorais