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

Only clear the duration when we really exit the field

Oliver Günther076702d4bbd5
diff --git a/frontend/src/app/shared/components/datepicker/multi-date-modal/multi-date.modal.html b/frontend/src/app/shared/components/datepicker/multi-date-modal/multi-date.modal.html
index 6ca34532283..1ca00a828d5 100644
--- a/frontend/src/app/shared/components/datepicker/multi-date-modal/multi-date.modal.html
+++ b/frontend/src/app/shared/components/datepicker/multi-date-modal/multi-date.modal.html
@@ -111,6 +111,7 @@
<div class="form--field-container">
<div class="form--text-field-container op-datepicker-modal--date-container">
<spot-text-field
+ #durationField
name="duration"
data-qa-selector="op-datepicker-modal--duration-field"
class="op-datepicker-modal--date-field"
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.ts
index 402a2d42b81..a7fca9f12ef 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
@@ -71,6 +71,7 @@ import {
validDate,
} from 'core-app/shared/components/datepicker/helpers/date-modal.helpers';
import { debugLog } from 'core-app/shared/helpers/debug_output';
+import { whenOutside } from 'core-app/shared/directives/focus/contain-helpers';
export type DateKeys = 'start'|'end';
export type DateFields = DateKeys|'duration';
@@ -113,6 +114,8 @@ export class MultiDateModalComponent extends OpModalComponent implements AfterVi
@ViewChild('modalContainer') modalContainer:ElementRef<HTMLElement>;
+ @ViewChild('durationField', { read: ElementRef }) durationField:ElementRef<HTMLElement>;
+
text = {
save: this.I18n.t('js.button_save'),
cancel: this.I18n.t('js.button_cancel'),
@@ -399,9 +402,8 @@ export class MultiDateModalComponent extends OpModalComponent implements AfterVi
}
handleDurationFocusOut():void {
- // Apply changed duration with a timeout
- // in case we clicked the clear button
- setTimeout(() => this.applyChangedDuration(), 25);
+ // Apply changed duration once we really exited the field
+ whenOutside(this.durationField.nativeElement, () => this.applyChangedDuration());
}
applyChangedDuration():void {
diff --git a/spec/features/work_packages/datepicker/datepicker_logic_spec.rb b/spec/features/work_packages/datepicker/datepicker_logic_spec.rb
index 0f1d9e84678..a974e014648 100644
--- a/spec/features/work_packages/datepicker/datepicker_logic_spec.rb
+++ b/spec/features/work_packages/datepicker/datepicker_logic_spec.rb
@@ -220,6 +220,8 @@ describe 'Datepicker modal logic test cases (WP #43539)',
datepicker.expect_due_date '2021-02-12'
datepicker.expect_duration 3
+ # The spec clears faster than the due date is filled, wait a bit
+ sleep 1
datepicker.clear_duration
datepicker.expect_start_date '2021-02-09'