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

Check for fieldValue to be existent before relying on it

Henriette Dargea70a3ae7cda1
diff --git a/frontend/src/app/features/invite-user-modal/principal/principal.component.ts b/frontend/src/app/features/invite-user-modal/principal/principal.component.ts
index 2de2c62498d..805b85e812c 100644
--- a/frontend/src/app/features/invite-user-modal/principal/principal.component.ts
+++ b/frontend/src/app/features/invite-user-modal/principal/principal.component.ts
@@ -244,7 +244,7 @@ export class PrincipalComponent implements OnInit {
const fieldSchema = fieldsSchema[fieldKey];
let fieldValue = this.customFields[fieldKey];
- if (fieldSchema.location === '_links') {
+ if (fieldSchema.location === '_links' && !!fieldValue) {
fieldValue = Array.isArray(fieldValue)
? fieldValue.map((opt:any) => (opt._links ? opt._links.self : opt))
: (fieldValue._links ? fieldValue._links.self : fieldValue);
diff --git a/spec/features/users/invite_user_modal/invite_user_modal_spec.rb b/spec/features/users/invite_user_modal/invite_user_modal_spec.rb
index 635c3fd7169..33cd913c13e 100644
--- a/spec/features/users/invite_user_modal/invite_user_modal_spec.rb
+++ b/spec/features/users/invite_user_modal/invite_user_modal_spec.rb
@@ -160,6 +160,27 @@ RSpec.describe "Invite user modal", :js, :with_cuprite do
let(:mail_membership_recipients) { [principal] }
end
end
+
+ context "with a required list user CF (regression #58429)" do
+ let(:current_user) { create(:admin) }
+ let(:list_cf) do
+ create(:user_custom_field,
+ :list,
+ name: "List",
+ is_required: true,
+ editable: false,
+ default_option: "A")
+ end
+
+ before do
+ list_cf
+ end
+
+ it_behaves_like "invites the principal to the project" do
+ let(:added_principal) { principal }
+ let(:mail_membership_recipients) { [principal] }
+ end
+ end
end
context "with a user to be invited" do