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 show default if no actual value has been selected

Markus Kahl27a7c24fef14
diff --git a/app/forms/custom_fields/inputs/single_select_list.rb b/app/forms/custom_fields/inputs/single_select_list.rb
index 2eb3711d0f7..137c249c590 100644
--- a/app/forms/custom_fields/inputs/single_select_list.rb
+++ b/app/forms/custom_fields/inputs/single_select_list.rb
@@ -80,6 +80,18 @@ class CustomFields::Inputs::SingleSelectList < CustomFields::Inputs::Base::Autoc
end
def selected?(custom_option)
- custom_option.id == @custom_value.value&.to_i || custom_option.id == @custom_field.default_value&.to_i
+ custom_option.id == selected_id
+ end
+
+ ##
+ # Returns the ID of the selected CustomOption,
+ # the default option ID if none is selected, or
+ # nil if there is no default.
+ def selected_id
+ if @custom_value.value.present?
+ @custom_value.value.to_i
+ else
+ @custom_field.default_value&.to_i
+ end
end
end