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

Take care that the debounce actually uses the updated variable

Henriette Darged08c8eef4a22
diff --git a/frontend/src/app/shared/components/datepicker/datepicker.modal.ts b/frontend/src/app/shared/components/datepicker/datepicker.modal.ts
index 03a753043c0..070a8995959 100644
--- a/frontend/src/app/shared/components/datepicker/datepicker.modal.ts
+++ b/frontend/src/app/shared/components/datepicker/datepicker.modal.ts
@@ -53,11 +53,14 @@ import { DayElement } from 'flatpickr/dist/types/instance';
import flatpickr from 'flatpickr';
import { DatepickerModalService } from 'core-app/shared/components/datepicker/datepicker.modal.service';
import {
- debounceTime,
+ debounce,
take,
} from 'rxjs/operators';
import { activeFieldContainerClassName } from 'core-app/shared/components/fields/edit/edit-form/edit-form';
-import { Subject } from 'rxjs';
+import {
+ Subject,
+ timer,
+} from 'rxjs';
export type DateKeys = 'date'|'start'|'end';
@@ -160,12 +163,14 @@ export class DatePickerModalComponent extends OpModalComponent implements AfterV
// 2. So he/she starts entering the finish date 2022-07-1 .
// 3. This is already a valid date. Since it is before the start date,the start date would be changed automatically to the first without the debounce.
// 4. The debounce gives the user enough time to type the last number "9" before the changes are converted to the datepicker and the start date would be affected.
- // debounce delay is 0 for initial display, and then set to 800
- debounceTime(this.debounceDelay),
+ //
+ // Debounce delay is 0 for initial display, and then set to 800
+ debounce(() => timer(this.debounceDelay)),
)
.subscribe(() => {
// set debounce delay to its real value
this.debounceDelay = 800;
+
// Always update the whole form to ensure that no values are lost/inconsistent
if (this.singleDate) {
this.updateDate('date', this.dates.date);