-
-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Flatpickr Improvements #119
base: main
Are you sure you want to change the base?
Conversation
@fballiano are you interested and/or have time to work on this at all? I figure you have some ideas for this. |
@fballiano -- just tagging you again in case you didn't see this. |
Sorry, I thought I could finish the captcha more quickly and then answer here but... |
No problem, just making sure you saw it. Worst case, we just add the one line to support the dialog usage before release: const flatpickrOptions = {
// ...
static: !!inputEl.closest('dialog'),
} |
mmm I lean toward thinking that I'd prefer to keep the php as agnostic as possibile, in the sense that these js libraries come and go and the less we're tied to them the more we're free. and to have it both in php and js IMHO could bring more possible bugs if we change one and forget the other.
I can't test the backend "for real" cause it seems I can't login via passkey on mobile, very weird. But It seems to me you already did everything in this PR right? |
Yes, I had the same concern about supporting formats in both JS and PHP, was sort of just throwing out ideas. So then let's just continue to use
The mobile thing should be fixed, but I don't have an up to date Android phone to test. The problem was a combination of the lazy loading and The main TODO here is the combination datetime, and regular time inputs. Flatpickr seems nice that even with native mobile inputs, it formats the date how we ask it to. Before time inputs sent data as multiple fields (hour, minute, am/pm), but now it would all be crammed into
Hm, I also cannot login via mobile (Chrome on iOS). I never disabled password auth so I didn't notice.
|
First commit (e9f2dc0) is a backup of the commit dropped from #106.
Second commit (db1d96b) was me working on improving our date picker:
Use flatpickr time selector
Product custom options has date, datetime, and time options. Below is how they appear on main:

Below is how the latter two now appear with this PR:

Luckily, there is no concept of timezones in the Magento product option, it's just a time (i.e. "09:00") that gets converted to 24h format for the DB. But actually I didn't finish the saving time values to the DB, that needs to be done in this file, currently they used some regex but maybe there's a better way to parse it.
Fix
<depends>
config nodeIn System > Config > Catalog > Date & Time Custom Options, all the config nodes depended on the JS calendar being enabled, but this doesn't make sense as all the options are used when the JS is disabled.
Mage_Core_Block_Html_Date
updatesI know you didn't touch this class much, but we will need to break some compatibility here to enable time only inputs. Mage has an
enableTime
option, but it doesn't have a way to enable / disable the date picker separately from the time input.So far I've added a new
setConfig()
method intended to control flatpickr options not present on the current PHP class. I think we can expand this class to support flatpickr directly instead of hacking around it in JS. For example, can we convert to flatpickr's format in PHP instead of JS? Right now the format is underconfig.ifFormat
, so maybe add support forconfig.fpFormat
. Maybe detect which one is present in JS act support both?JS updates
Flatpickr wasn't working great on mobile for me, and it was caused by the instance not loading until the input has a focus or click event, and which time flatpickr would load, detect mobile, and turn it into a native input. I changed this so that inputs are initialized during the
Calendar.setup()
call.I also had to fix one character in
strftimeToDateConvertionMap
related to AM / PM. That was'%p': 'A'
->'%p': 'K'
. It seems flatpickr uses it's own slightly custom set of formatting tokens.Note: there's a temp debug line in the JS to set the format to
m/j/Y h:i K
. But it seems that format is valid for all of date, datetime, and time pickers...