-
-
Save sajjadanwar0/40bd8603688ef42806bea5ef3a936b92 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Fix for Firefox | |
// Can be removed after release with this patch in: https://github.com/flatpickr/flatpickr/pull/1879 | |
const brokenInputs = [ | |
input._flatpickr.hourElement, | |
input._flatpickr.minuteElement, | |
]; | |
brokenInputs.forEach(input => { | |
input.addEventListener('input', e => { | |
// Date isn't updated if you close the popup without pressing enter on Firefox, we can resolve this by blurring | |
// then focusing straight away | |
e.target.blur(); | |
e.target.focus(); | |
// After we've given focus back, it selects the whole input, so if the user types in anything it overwrites what's | |
// already there. We can force the browser to put the cursor at the end of the input by clearing and re-filling | |
// the value | |
const { value } = e.target; | |
e.target.value = ''; | |
e.target.value = value; | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment