Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Add the value change detection method back for the datepicker trigger input

Dombi Attila210ae232548a
diff --git a/frontend/src/app/shared/components/datepicker/single-date-picker/single-date-picker.component.html b/frontend/src/app/shared/components/datepicker/single-date-picker/single-date-picker.component.html
index 62c9c9952f7..c70b96fabf2 100644
--- a/frontend/src/app/shared/components/datepicker/single-date-picker/single-date-picker.component.html
+++ b/frontend/src/app/shared/components/datepicker/single-date-picker/single-date-picker.component.html
@@ -13,7 +13,8 @@
class="spot-input"
[attr.data-value]="value"
[id]="id"
- [value]="value"
+ [(ngModel)]="value"
+ (ngModelChange)="changeValueFromInputDebounced($event)"
(click)="onInputClick($event)"
(focus)="opened = true"
/>
diff --git a/frontend/src/app/shared/components/datepicker/single-date-picker/single-date-picker.component.ts b/frontend/src/app/shared/components/datepicker/single-date-picker/single-date-picker.component.ts
index da74bc22116..64a935b9593 100644
--- a/frontend/src/app/shared/components/datepicker/single-date-picker/single-date-picker.component.ts
+++ b/frontend/src/app/shared/components/datepicker/single-date-picker/single-date-picker.component.ts
@@ -54,7 +54,6 @@ import { DayElement } from 'flatpickr/dist/types/instance';
import { populateInputsFromDataset } from '../../dataset-inputs';
import { debounce } from 'lodash';
import { SpotDropModalTeleportationService } from 'core-app/spot/components/drop-modal/drop-modal-teleportation.service';
-import { filter } from 'rxjs/operators';
export const opSingleDatePickerSelector = 'op-single-date-picker';
@@ -183,6 +182,24 @@ export class OpSingleDatePickerComponent implements ControlValueAccessor, AfterC
this.cdRef.detectChanges();
}
+ changeValueFromInputDebounced = debounce(this.changeValueFromInput.bind(this), 16);
+
+ changeValueFromInput(value:string) {
+ this.valueChange.emit(value);
+ this.onChange(value);
+ this.writeValue(value);
+
+ const date = parseDate(value || '');
+
+ if (date !== '') {
+ const dateString = this.timezoneService.formattedISODate(date);
+ this.writeWorkingValue(dateString);
+ this.enforceManualChangesToDatepicker(date);
+ this.onTouched(dateString);
+ }
+ this.cdRef.detectChanges();
+ }
+
private enforceManualChangesToDatepicker(enforceDate?:Date) {
const date = parseDate(this.workingDate || '');
setDates(date, this.datePickerInstance, enforceDate);