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

Refactor the focus toggling mechanism on the wp-multi-datepicker

Dombi Attila4b379f0f7ca1
diff --git a/frontend/src/app/shared/components/datepicker/wp-multi-date-form/wp-multi-date-form.component.ts b/frontend/src/app/shared/components/datepicker/wp-multi-date-form/wp-multi-date-form.component.ts
index c325a8a2a86..4805813af48 100644
--- a/frontend/src/app/shared/components/datepicker/wp-multi-date-form/wp-multi-date-form.component.ts
+++ b/frontend/src/app/shared/components/datepicker/wp-multi-date-form/wp-multi-date-form.component.ts
@@ -195,8 +195,10 @@ export class OpWpMultiDateFormComponent extends UntilDestroyedMixin implements A
this.clearWithDuration(field);
}
- if (field === 'start') {
- this.setCurrentActivatedField('end');
+ // The duration field is special in how it handles focus transitions
+ // For start/due we just toggle here
+ if (field !== 'duration') {
+ this.toggleCurrentActivatedField();
}
this.cdRef.detectChanges();
@@ -383,9 +385,6 @@ export class OpWpMultiDateFormComponent extends UntilDestroyedMixin implements A
setToday(key:DateKeys):void {
this.datepickerChanged$.next([key, new Date()]);
-
- const nextActive = key === 'start' ? 'end' : 'start';
- this.setCurrentActivatedField(nextActive);
}
showTodayLink():boolean {
@@ -493,12 +492,6 @@ export class OpWpMultiDateFormComponent extends UntilDestroyedMixin implements A
// Update with the same flow as entering a value
const { latestSelectedDateObj } = instance as { latestSelectedDateObj:Date };
this.datepickerChanged$.next([activeField, latestSelectedDateObj]);
-
- // The duration field is special in how it handles focus transitions
- // For start/due we just toggle here
- if (activeField !== 'duration') {
- this.toggleCurrentActivatedField();
- }
},
// eslint-disable-next-line @typescript-eslint/no-misused-promises
onDayCreate: async (dObj:Date[], dStr:string, fp:flatpickr.Instance, dayElem:DayElement) => {
diff --git a/spec/features/work_packages/details/date_editor_spec.rb b/spec/features/work_packages/details/date_editor_spec.rb
index 0a5d739aa8c..6f6a5a7e850 100644
--- a/spec/features/work_packages/details/date_editor_spec.rb
+++ b/spec/features/work_packages/details/date_editor_spec.rb
@@ -147,7 +147,7 @@ describe 'date inplace editor',
# Focus the end date field
start_date.activate_due_date_within_modal
- start_date.datepicker.set_date '2016-03-01'
+ start_date.datepicker.set_due_date '2016-03-01'
# Since the end date is focused, the date will become the new end date
start_date.save!
@@ -160,7 +160,7 @@ describe 'date inplace editor',
start_date.datepicker.expect_year '2016'
start_date.datepicker.expect_month 'January'
- start_date.datepicker.set_date '2016-04-01'
+ start_date.datepicker.set_start_date '2016-04-01'
# This will set the new start and unset the end date
start_date.save!
@@ -201,7 +201,7 @@ describe 'date inplace editor',
# Expect due date to be focused as it is empty
start_date.expect_due_highlighted
- start_date.set_active_date Time.zone.today
+ start_date.set_due_date Time.zone.today
# Wait for duration to be derived
start_date.expect_duration /\d+ days/
@@ -209,7 +209,7 @@ describe 'date inplace editor',
# As the to be selected date is automatically toggled,
# we can directly set the start date afterwards to the same day
start_date.expect_start_highlighted
- start_date.set_active_date Time.zone.today
+ start_date.set_start_date Time.zone.today
start_date.expect_duration 1
start_date.save!