diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 7f007135..ab046469 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -65,6 +65,7 @@ module ApplicationHelper { class: "form-control #{invalid(metadata.post, attribute)}", required: metadata.required, + autofocus: (metadata.post.attributes.first == attribute), aria: { describedby: id_for_help(attribute), required: metadata.required diff --git a/app/views/posts/_form.haml b/app/views/posts/_form.haml index 2b92b613..26b4e183 100644 --- a/app/views/posts/_form.haml +++ b/app/views/posts/_form.haml @@ -29,7 +29,8 @@ = render("posts/attributes/#{type}", post: post, attribute: attribute, - metadata: metadata, site: site) + metadata: metadata, site: site, + autofocus: (post.attributes.first == attribute)) -# Botones de guardado = render 'posts/submit', site: site, post: post diff --git a/app/views/posts/attributes/_boolean.haml b/app/views/posts/attributes/_boolean.haml index 55d69176..976c4b86 100644 --- a/app/views/posts/attributes/_boolean.haml +++ b/app/views/posts/attributes/_boolean.haml @@ -1,7 +1,8 @@ .form-check = check_box_tag "post[#{attribute}", metadata.value, metadata.value, class: "form-check-input #{invalid(post, attribute)}", - aria: { describedby: id_for_help(attribute) } + aria: { describedby: id_for_help(attribute) }, + autofocus: autofocus = label_tag "post_#{attribute}", post_label_t(attribute, post: post), class: 'form-check-label'