diff --git a/plinth/modules/networks/forms.py b/plinth/modules/networks/forms.py
index d443a44c2..91cae9896 100644
--- a/plinth/modules/networks/forms.py
+++ b/plinth/modules/networks/forms.py
@@ -32,6 +32,12 @@ class ConnectionTypeSelectForm(forms.Form):
choices=[(key, value)
for key, value in network.CONNECTION_TYPE_NAMES.items()])
+ def __init__(self, *args, **kwargs):
+ super().__init__(*args, **kwargs)
+ self.fields['connection_type'].widget.attrs.update({
+ 'autofocus': 'autofocus'
+ })
+
class ConnectionForm(forms.Form):
"""Base form to create/edit a connection."""
diff --git a/plinth/modules/networks/templates/connections_type_select.html b/plinth/modules/networks/templates/connections_type_select.html
index 99eef9387..dbebf5e2c 100644
--- a/plinth/modules/networks/templates/connections_type_select.html
+++ b/plinth/modules/networks/templates/connections_type_select.html
@@ -33,9 +33,3 @@
{% endblock %}
-
-{% block page_js %}
-
-{% endblock %}
diff --git a/plinth/modules/pagekite/forms.py b/plinth/modules/pagekite/forms.py
index 8235bf882..ddf6c439c 100644
--- a/plinth/modules/pagekite/forms.py
+++ b/plinth/modules/pagekite/forms.py
@@ -279,6 +279,11 @@ class FirstBootForm(forms.Form):
widget=SubdomainWidget(domain=DOMAIN_APPENDIX),
help_text=_('The subdomain you want to register'))
+ def __init__(self, *args, **kwargs):
+ """Initialize the form."""
+ super().__init__(*args, **kwargs)
+ self.fields['code'].widget.attrs.update({'autofocus': 'autofocus'})
+
def clean_domain(self):
"""Append the domain to the users' subdomain"""
return self.cleaned_data['domain'] + self.DOMAIN_APPENDIX
diff --git a/plinth/modules/pagekite/templates/pagekite_firstboot.html b/plinth/modules/pagekite/templates/pagekite_firstboot.html
index 5c7dcd1e3..6a22cbcd4 100644
--- a/plinth/modules/pagekite/templates/pagekite_firstboot.html
+++ b/plinth/modules/pagekite/templates/pagekite_firstboot.html
@@ -59,9 +59,3 @@
{% endblock %}
-
-{% block page_js %}
-
-{% endblock %}
diff --git a/plinth/modules/sharing/forms.py b/plinth/modules/sharing/forms.py
index e36aa371c..23c029193 100644
--- a/plinth/modules/sharing/forms.py
+++ b/plinth/modules/sharing/forms.py
@@ -50,6 +50,7 @@ class AddShareForm(forms.Form):
"""Initialize the form with extra request argument."""
super().__init__(*args, **kwargs)
self.fields['groups'].choices = get_group_choices()
+ self.fields['name'].widget.attrs.update({'autofocus': 'autofocus'})
def clean_name(self):
"""Check if the name is valid."""
diff --git a/plinth/modules/sharing/templates/sharing_add_edit.html b/plinth/modules/sharing/templates/sharing_add_edit.html
index d2b752c95..97150a2a7 100644
--- a/plinth/modules/sharing/templates/sharing_add_edit.html
+++ b/plinth/modules/sharing/templates/sharing_add_edit.html
@@ -35,9 +35,3 @@
{% endblock %}
-
-{% block page_js %}
-
-{% endblock %}
diff --git a/plinth/modules/sso/forms.py b/plinth/modules/sso/forms.py
index e3bab04e8..fb2b095d5 100644
--- a/plinth/modules/sso/forms.py
+++ b/plinth/modules/sso/forms.py
@@ -23,4 +23,9 @@ from captcha.fields import CaptchaField
class AuthenticationForm(DjangoAuthenticationForm):
+ """Authentication form with an additional Captcha field."""
captcha = CaptchaField()
+
+ def __init__(self, *args, **kwargs):
+ super().__init__(*args, **kwargs)
+ self.fields['username'].widget.attrs.update({'autofocus': 'autofocus'})
diff --git a/plinth/modules/sso/templates/login.html b/plinth/modules/sso/templates/login.html
index 79610ff9c..f5673bffd 100644
--- a/plinth/modules/sso/templates/login.html
+++ b/plinth/modules/sso/templates/login.html
@@ -41,9 +41,3 @@
{% endblock %}
-
-{% block page_js %}
-
-{% endblock %}
diff --git a/plinth/modules/users/forms.py b/plinth/modules/users/forms.py
index 16e9807de..8f81b0d59 100644
--- a/plinth/modules/users/forms.py
+++ b/plinth/modules/users/forms.py
@@ -107,6 +107,7 @@ class CreateUserForm(ValidNewUsernameCheckMixin,
self.request = request
super(CreateUserForm, self).__init__(*args, **kwargs)
self.fields['groups'].choices = get_group_choices()
+ self.fields['username'].widget.attrs.update({'autofocus': 'autofocus'})
def save(self, commit=True):
"""Save the user model and create LDAP user if required."""
@@ -176,6 +177,7 @@ class UserUpdateForm(ValidNewUsernameCheckMixin,
self.username = username
super(UserUpdateForm, self).__init__(*args, **kwargs)
self.is_last_admin_user = get_last_admin_user() == self.username
+ self.fields['username'].widget.attrs.update({'autofocus': 'autofocus'})
choices = []
@@ -286,6 +288,9 @@ class UserChangePasswordForm(SetPasswordForm):
"""Initialize the form with extra request argument."""
self.request = request
super(UserChangePasswordForm, self).__init__(*args, **kwargs)
+ self.fields['new_password1'].widget.attrs.update({
+ 'autofocus': 'autofocus'
+ })
def save(self, commit=True):
"""Save the user model and change LDAP password as well."""
@@ -309,6 +314,7 @@ class FirstBootForm(ValidNewUsernameCheckMixin, auth.forms.UserCreationForm):
def __init__(self, *args, **kwargs):
self.request = kwargs.pop('request')
super().__init__(*args, **kwargs)
+ self.fields['username'].widget.attrs.update({'autofocus': 'autofocus'})
def save(self, commit=True):
"""Create and log the user in."""
diff --git a/plinth/modules/users/templates/users_change_password.html b/plinth/modules/users/templates/users_change_password.html
index 6ac0a2b76..3ddabc301 100644
--- a/plinth/modules/users/templates/users_change_password.html
+++ b/plinth/modules/users/templates/users_change_password.html
@@ -37,8 +37,3 @@
{% endblock %}
-{% block page_js %}
-
-{% endblock %}
diff --git a/plinth/modules/users/templates/users_create.html b/plinth/modules/users/templates/users_create.html
index 4d8f0f4f0..5476250a6 100644
--- a/plinth/modules/users/templates/users_create.html
+++ b/plinth/modules/users/templates/users_create.html
@@ -34,8 +34,3 @@
{% endblock %}
-{% block page_js %}
-
-{% endblock %}
diff --git a/plinth/modules/users/templates/users_firstboot.html b/plinth/modules/users/templates/users_firstboot.html
index cc591e2de..345ec9b91 100644
--- a/plinth/modules/users/templates/users_firstboot.html
+++ b/plinth/modules/users/templates/users_firstboot.html
@@ -43,8 +43,3 @@
{% endblock %}
-{% block page_js %}
-
-{% endblock %}
diff --git a/plinth/modules/users/templates/users_update.html b/plinth/modules/users/templates/users_update.html
index c50536815..41fd09930 100644
--- a/plinth/modules/users/templates/users_update.html
+++ b/plinth/modules/users/templates/users_update.html
@@ -43,8 +43,3 @@
{% endblock %}
-{% block page_js %}
-
-{% endblock %}