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

With duration in focus, the datepicker is clicked. In that case we have to decide wich field the value is for. The due date should be seleected when it is empty AND (the start date is either filled OR not touched). The later is basically the case when the datepicker is in single date mode

Henriette Darge23d103ba6534
diff --git a/frontend/src/stimulus/controllers/dynamic/work-packages/date-picker/preview.controller.ts b/frontend/src/stimulus/controllers/dynamic/work-packages/date-picker/preview.controller.ts
index 95398ea1f37..1c0b3cc3b52 100644
--- a/frontend/src/stimulus/controllers/dynamic/work-packages/date-picker/preview.controller.ts
+++ b/frontend/src/stimulus/controllers/dynamic/work-packages/date-picker/preview.controller.ts
@@ -181,8 +181,8 @@ export default class PreviewController extends DialogPreviewController {
let dateFieldToChange:HTMLInputElement;
if (this.highlightedField === this.dueDateField
|| (this.highlightedField === this.durationField
- && this.currentStartDate !== null
- && this.currentDueDate === null)) {
+ && (this.currentStartDate !== null || !this.isTouched('start_date'))
+ && this.currentDueDate === null)) {
dateFieldToChange = this.dueDateField;
} else {
dateFieldToChange = this.startDateField;
diff --git a/spec/features/work_packages/datepicker/datepicker_single_date_mode_logic_spec.rb b/spec/features/work_packages/datepicker/datepicker_single_date_mode_logic_spec.rb
index d52ee2a254c..7b70ad19ce4 100644
--- a/spec/features/work_packages/datepicker/datepicker_single_date_mode_logic_spec.rb
+++ b/spec/features/work_packages/datepicker/datepicker_single_date_mode_logic_spec.rb
@@ -111,6 +111,39 @@ RSpec.describe "Datepicker: Single-date mode logic test cases (WP #61146)", :js,
end
end
+ context "when adding a duration and a date to a new work package (scenario 1b)" do
+ let(:current_attributes) do
+ {
+ start_date: nil,
+ due_date: nil,
+ duration: nil
+ }
+ end
+
+ it "takes the new date as finish date and calculates the start date" do
+ datepicker.expect_start_date "", visible: false
+ datepicker.expect_due_date ""
+ datepicker.expect_duration ""
+
+ datepicker.focus_duration
+ datepicker.set_duration "3"
+
+ datepicker.expect_start_date "", visible: false
+ datepicker.expect_due_date ""
+ datepicker.expect_duration "3"
+
+ datepicker.expect_duration_highlighted
+
+ datepicker.set_date "2025-02-14"
+
+ datepicker.expect_start_date "2025-02-12"
+ datepicker.expect_due_date "2025-02-14"
+ datepicker.expect_duration "3"
+
+ datepicker.expect_start_highlighted
+ end
+ end
+
describe "when adding a start date to a new work package (scenario 2)" do
let(:current_attributes) do
{