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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Fix toggling active field when duration is active
Oliver Günthera3a481428da9
diff --git a/frontend/src/app/shared/components/datepicker/multi-date-modal/multi-date.modal.ts b/frontend/src/app/shared/components/datepicker/multi-date-modal/multi-date.modal.tsindex 0ccb2d89eca..e7c403c85af 100644--- a/frontend/src/app/shared/components/datepicker/multi-date-modal/multi-date.modal.ts+++ b/frontend/src/app/shared/components/datepicker/multi-date-modal/multi-date.modal.ts@@ -313,7 +313,7 @@ export class MultiDateModalComponent extends OpModalComponent implements AfterViif ((val === null || validDate(val)) && this.datePickerInstance) {this.dates[key] = mappedDate(val);const dateValue = parseDate(val || '') || undefined;- this.enforceManualChangesToDatepicker(false, dateValue);+ this.enforceManualChangesToDatepicker(dateValue);this.cdRef.detectChanges();}}@@ -335,7 +335,8 @@ export class MultiDateModalComponent extends OpModalComponent implements AfterVithis.dates[key] = this.timezoneService.formattedISODate(today);if (today instanceof Date) {- this.enforceManualChangesToDatepicker(true, today);+ this.enforceManualChangesToDatepicker(today);+ this.toggleCurrentActivatedField();} else {this.enforceManualChangesToDatepicker();}@@ -444,7 +445,16 @@ export class MultiDateModalComponent extends OpModalComponent implements AfterVionReady: () => {this.reposition(jQuery(this.modalContainer.nativeElement), jQuery(`.${activeFieldContainerClassName}`));},- onChange: (dates:Date[]) => this.datepickerChanged$.next([this.currentlyActivatedDateField, dates]),+ onChange: (dates:Date[]) => {+ const activeField = this.currentlyActivatedDateField;+ this.datepickerChanged$.next([activeField, dates]);++ // The duration field is special in how it handles focus transitions+ // For start/due we just toggle here+ if (activeField !== 'duration') {+ this.toggleCurrentActivatedField();+ }+ },onDayCreate: (dObj:Date[], dStr:string, fp:flatpickr.Instance, dayElem:DayElement) => {onDayCreate(dayElem,@@ -459,7 +469,7 @@ export class MultiDateModalComponent extends OpModalComponent implements AfterVi);}- private enforceManualChangesToDatepicker(toggleField = true, enforceDate?:Date) {+ private enforceManualChangesToDatepicker(enforceDate?:Date) {let startDate = parseDate(this.dates.start || '');let endDate = parseDate(this.dates.end || '');@@ -478,10 +488,6 @@ export class MultiDateModalComponent extends OpModalComponent implements AfterViconst dates = [startDate, endDate];setDates(dates, this.datePickerInstance, enforceDate);-- if (toggleField) {- this.toggleCurrentActivatedField();- }}private handleDatePickerChange(activeField:DateFields, dates:Date[]) {@@ -501,7 +507,6 @@ export class MultiDateModalComponent extends OpModalComponent implements AfterVithis.durationActiveDateSelected(dates[0]);} else if (this.dates.start && this.dates.end) {this.formUpdates$.next({ startDate: this.dates.start, dueDate: this.dates.end });- this.toggleCurrentActivatedField();}}@@ -520,8 +525,6 @@ export class MultiDateModalComponent extends OpModalComponent implements AfterVi// Active is on start or end, the other was missingthis.deriveOtherField(activeField);- // Toggle the active date to the other one- this.toggleCurrentActivatedField();}}@@ -596,7 +599,6 @@ export class MultiDateModalComponent extends OpModalComponent implements AfterVi// Reset duration and end datethis.duration = null;this.applyNewDates([selectedDate]);- this.toggleCurrentActivatedField();}} else if (areDatesEqual(selectedDate, parsedStartDate) || areDatesEqual(selectedDate, parsedEndDate)) {this.applyNewDates([selectedDate, selectedDate]);