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

[34424] Focus on project name field if empty

Oliver Günther94d19b74967d
diff --git a/app/views/projects/form/attributes/_name.html.erb b/app/views/projects/form/attributes/_name.html.erb
index 6723e0e0c58..ec4347921e4 100644
--- a/app/views/projects/form/attributes/_name.html.erb
+++ b/app/views/projects/form/attributes/_name.html.erb
@@ -31,6 +31,5 @@ See docs/COPYRIGHT.rdoc for more details.
<%= form.text_field :name,
required: true,
help_text: { attribute: :name, 'attribute-scope': :Project },
- autofocus: form.object&.name&.empty?,
container_class: '-wide' %>
</div>
diff --git a/frontend/src/app/modules/augmenting/dynamic-scripts/project_form_listener.js b/frontend/src/app/modules/augmenting/dynamic-scripts/project_form_listener.js
index 19b8d89c82c..0f9819b5f6e 100644
--- a/frontend/src/app/modules/augmenting/dynamic-scripts/project_form_listener.js
+++ b/frontend/src/app/modules/augmenting/dynamic-scripts/project_form_listener.js
@@ -119,8 +119,16 @@
});
}
+ function focusOnName() {
+ const name = document.getElementById('project_name');
+ if (!name.value) {
+ name.focus();
+ }
+ }
+
observeProjectIdentifier();
observeProjectName();
observeTemplateChanges();
+ focusOnName();
});
}(jQuery));