-
Notifications
You must be signed in to change notification settings - Fork 17
IBX-10653: flatpickr doesn't save seconds (unless minutes or other elements are changed afterwards) #1747
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
base: 4.6
Are you sure you want to change the base?
Conversation
…ements are changed afterwards)
4c2bd05 to
f27d459
Compare
|
| } | ||
|
|
||
| onKeyUp(isMinute, event) { | ||
| onKeyUp(isHour, isMinute, isSecond, event) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as only one of these is used in single call, it can be made into single variable
| onKeyUp(isHour, isMinute, isSecond, event) { | |
| onKeyUp(type, event) { |
| if (isHour) { | ||
| flatpickrDate.setHours(value); | ||
| } else if (isMinute) { | ||
| flatpickrDate.setMinutes(value); | ||
| } else if (isSecond) { | ||
| flatpickrDate.setSeconds(value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and with changing to single variable this can be remade
| if (isHour) { | |
| flatpickrDate.setHours(value); | |
| } else if (isMinute) { | |
| flatpickrDate.setMinutes(value); | |
| } else if (isSecond) { | |
| flatpickrDate.setSeconds(value); | |
| switch (type) { | |
| case 'hours': | |
| flatpickrDate.setHours(value); | |
| break; | |
| case 'minutes': | |
| flatpickrDate.setMinutes(value); | |
| break; | |
| case 'seconds': | |
| flatpickrDate.setSeconds(value); | |
| break; | |
| } |
or ifs if someone doesn't like switches ;)
| this.flatpickrInstance.hourElement.addEventListener('keyup', this.onKeyUp.bind(this, true, false, false), false); | ||
| this.flatpickrInstance.minuteElement.addEventListener('keyup', this.onKeyUp.bind(this, false, true, false), false); | ||
| this.flatpickrInstance.secondElement.addEventListener('keyup', this.onKeyUp.bind(this, false, false, true), false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and than here as well:
| this.flatpickrInstance.hourElement.addEventListener('keyup', this.onKeyUp.bind(this, true, false, false), false); | |
| this.flatpickrInstance.minuteElement.addEventListener('keyup', this.onKeyUp.bind(this, false, true, false), false); | |
| this.flatpickrInstance.secondElement.addEventListener('keyup', this.onKeyUp.bind(this, false, false, true), false); | |
| this.flatpickrInstance.hourElement.addEventListener('keyup', this.onKeyUp.bind(this, 'hours'), false); | |
| this.flatpickrInstance.minuteElement.addEventListener('keyup', this.onKeyUp.bind(this, 'minutes'), false); | |
| this.flatpickrInstance.secondElement.addEventListener('keyup', this.onKeyUp.bind(this, 'seconds'), false); |



Description:
Event listener for
secondelement missing, causing seconds not to be saved in the pickerFor QA:
Documentation: