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

[#67644] set autofocus on label only if form has no errors

Eric Schubert6c180a60b5ac
diff --git a/app/forms/custom_fields/hierarchy/item_form.rb b/app/forms/custom_fields/hierarchy/item_form.rb
index e75c8ecc81d..307e2da4b97 100644
--- a/app/forms/custom_fields/hierarchy/item_form.rb
+++ b/app/forms/custom_fields/hierarchy/item_form.rb
@@ -41,7 +41,7 @@ module CustomFields
value: @target_item.label,
visually_hide_label: true,
required: true,
- autofocus: true,
+ autofocus: @target_item.errors.empty?,
placeholder: I18n.t("custom_fields.admin.items.placeholder.label"),
validation_message: validation_message_for(:label)
)