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

Don't clear the datepicker input resulting in an endless loop

Oliver Günthere811d8b6f7a7
diff --git a/frontend/src/app/modules/common/op-date-picker/op-date-picker.component.ts b/frontend/src/app/modules/common/op-date-picker/op-date-picker.component.ts
index 336e0926274..349654ec20a 100644
--- a/frontend/src/app/modules/common/op-date-picker/op-date-picker.component.ts
+++ b/frontend/src/app/modules/common/op-date-picker/op-date-picker.component.ts
@@ -83,10 +83,10 @@ export class OpDatePickerComponent extends UntilDestroyedMixin implements OnDest
}
onInputChange(_event:KeyboardEvent) {
- if (this.isEmpty()) {
- this.datePickerInstance.clear();
- } else if (this.inputIsValidDate()) {
+ if (this.inputIsValidDate()) {
this.onChange.emit(this.currentValue);
+ } else {
+ this.onChange.emit('');
}
}
diff --git a/spec/features/work_packages/details/custom_fields/custom_field_spec.rb b/spec/features/work_packages/details/custom_fields/custom_field_spec.rb
index 41153392f17..8bd80840a2a 100644
--- a/spec/features/work_packages/details/custom_fields/custom_field_spec.rb
+++ b/spec/features/work_packages/details/custom_fields/custom_field_spec.rb
@@ -225,4 +225,30 @@ describe 'custom field inplace editor', js: true do
end
end
end
+
+ describe 'date type' do
+ let(:custom_field) do
+ FactoryBot.create(:date_wp_custom_field, args.merge(name: 'MyDate'))
+ end
+ let(:args) { {} }
+ let(:initial_custom_values) { {} }
+
+ it 'can set and clear the date (Regression #36727)' do
+ field.expect_state_text '-'
+ field.update '2021-03-30'
+ field.expect_state_text '03/30/2021'
+
+ work_package.reload
+ expect(work_package.custom_value_for(custom_field.id).formatted_value).to eq '03/30/2021'
+
+ field.activate!
+ field.clear
+ field.submit_by_enter
+
+ field.expect_state_text '-'
+
+ work_package.reload
+ expect(work_package.custom_value_for(custom_field.id).value).to be_nil
+ end
+ end
end