elm-datepicker
elm-datepicker copied to clipboard
Expose the Focus Msg via open
Potential solution for #85
Reason for diffs on other lines is due to elm format being automatically run. Can remove these changes if required.
Simple enough! Looking at the code, it seems like Focus
and MouseDown
differ in whether they set forceOpen
, which determines whether the picker will close when blurred. I don't have a strong opinion, but would you intuitively assume something called open
would force the picker open, or just transitorily open it and allow it to close itself?
We can always expose both, of course!
If you open the picker via the method I created it will stay open until you select a date (because the blur event which would usually happen never gets triggered). For me forceOpen
would mean that the datePicker wouldn't close when I select a date. Personally this is the not behaviour I am interested in and so have not exposed that, but it could be done in a similar way.
open
is also consistent with the isOpen
function, which is looking at the open attribute (and not forceOpen
)
I have added another commit with a close
method, which triggers this blur event (so that I can close the datepicker if the user loses focus of my other input) and tidied up the comments a bit