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 3da29a5d8c..99d8b2fa23 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 @@ -213,7 +213,8 @@ export class MultiDateModalComponent extends OpModalComponent implements AfterVi .pipe( this.untilDestroyed(), debounceTime(500), - map((value) => (value === '' ? null : parseInt(value, 10))), + map((value) => (value === '' ? null : Math.abs(parseInt(value, 10)))), + filter((val) => val === null || !Number.isNaN(val)), filter((val) => val !== this.duration), ) .subscribe((value) => this.applyDurationChange(value)); diff --git a/spec/features/work_packages/details/date_editor_spec.rb b/spec/features/work_packages/details/date_editor_spec.rb index 05cd0f1e43..ed146bb5a3 100644 --- a/spec/features/work_packages/details/date_editor_spec.rb +++ b/spec/features/work_packages/details/date_editor_spec.rb @@ -233,6 +233,17 @@ describe 'date inplace editor', start_date.expect_state_text "#{Time.zone.today.strftime('%Y-%m-%d')} - #{Time.zone.today.strftime('%Y-%m-%d')}" end + it 'can set a negative duration which gets transformed (Regression #44219)' do + start_date.activate! + start_date.expect_active! + + start_date.datepicker.expect_visible + start_date.datepicker.set_duration -128 + start_date.datepicker.focus_start_date + + start_date.datepicker.expect_duration 128 + end + it 'saves the date when clearing and then confirming' do start_date.activate!