Skip to content

Conversation

@vidarl
Copy link
Contributor

@vidarl vidarl commented Oct 17, 2025

🎫 Issue IBX-10653

Description:

Event listener for second element missing, causing seconds not to be saved in the picker

For QA:

Documentation:

@vidarl vidarl force-pushed the IBX-10653_flatpickr_doesnt_save_seconds_unless_minutes_or_other_elements_are_changed_afterwards branch from 4c2bd05 to f27d459 Compare October 17, 2025 09:14
@sonarqubecloud
Copy link

}

onKeyUp(isMinute, event) {
onKeyUp(isHour, isMinute, isSecond, event) {
Copy link
Contributor

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

Suggested change
onKeyUp(isHour, isMinute, isSecond, event) {
onKeyUp(type, event) {

Comment on lines +123 to +128
if (isHour) {
flatpickrDate.setHours(value);
} else if (isMinute) {
flatpickrDate.setMinutes(value);
} else if (isSecond) {
flatpickrDate.setSeconds(value);
Copy link
Contributor

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

Suggested change
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 ;)

Comment on lines +153 to +155
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);
Copy link
Contributor

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:

Suggested change
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);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants