Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions src/bundle/Resources/public/js/scripts/core/date.time.picker.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class DateTimePicker {
}
}

onKeyUp(isMinute, event) {
onKeyUp(type, event) {
const inputValue = event.target.value;

if (inputValue.length === 0) {
Expand All @@ -120,10 +120,16 @@ class DateTimePicker {
return;
}

if (isMinute) {
flatpickrDate.setMinutes(value);
} else {
flatpickrDate.setHours(value);
switch (type) {
case 'hours':
flatpickrDate.setHours(value);
break;
case 'minutes':
flatpickrDate.setMinutes(value);
break;
case 'seconds':
flatpickrDate.setSeconds(value);
break;
}

if (this.flatpickrInstance.config.minDate?.getTime() > flatpickrDate.getTime()) {
Expand All @@ -150,8 +156,11 @@ class DateTimePicker {
);

if (this.flatpickrInstance.config.enableTime) {
this.flatpickrInstance.minuteElement.addEventListener('keyup', this.onKeyUp.bind(this, true), false);
this.flatpickrInstance.hourElement.addEventListener('keyup', this.onKeyUp.bind(this, false), false);
this.flatpickrInstance.hourElement.addEventListener('keyup', this.onKeyUp.bind(this, 'hours'), false);
this.flatpickrInstance.minuteElement.addEventListener('keyup', this.onKeyUp.bind(this, 'minutes'), false);
if (this.flatpickrInstance.secondElement !== undefined) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI : I also had to add this check as the existences of the secondElement is dependent on config: https://github.com/ibexa/admin-ui-assets/blob/v4.6.25/src/bundle/Resources/public/vendors/flatpickr/dist/esm/index.js#L722-L725

this.flatpickrInstance.secondElement.addEventListener('keyup', this.onKeyUp.bind(this, 'seconds'), false);
}
}
}
}
Expand Down
Loading