Fix auto-focus username for login form

This commit is contained in:
Lance Edgar 2023-02-03 19:51:50 -06:00
parent f71eadd409
commit 15fb7f45b8
2 changed files with 14 additions and 0 deletions

View file

@ -57,5 +57,15 @@
</div>
</%def>
<%def name="modify_this_page_vars()">
<script type="text/javascript">
TailboneForm.mounted = function() {
this.$refs.username.focus()
}
</script>
</%def>
${parent.body()}

View file

@ -122,6 +122,10 @@ class AuthenticationView(View):
'tailbone', 'main_image_url',
default=self.request.static_url('tailbone:static/img/home_logo.png'))
# nb. hacky..but necessary, to add the ref, for autofocus
dform = form.make_deform_form()
dform['username'].widget.attributes = {'ref': 'username'}
return {
'form': form,
'referrer': referrer,