diff --git a/tailbone/templates/deform/password.pt b/tailbone/templates/deform/password.pt index d81b570f..b74d763a 100644 --- a/tailbone/templates/deform/password.pt +++ b/tailbone/templates/deform/password.pt @@ -9,7 +9,8 @@ tal:omit-tag=""> + type="password" + tal:attributes="attributes|field.widget.attributes|{};"> diff --git a/tailbone/templates/login.mako b/tailbone/templates/login.mako index f53de560..6e6e347f 100644 --- a/tailbone/templates/login.mako +++ b/tailbone/templates/login.mako @@ -64,6 +64,13 @@ this.$refs.username.focus() } + TailboneForm.methods.usernameKeydown = function(event) { + if (event.which == 13) { + event.preventDefault() + this.$refs.password.focus() + } + } + diff --git a/tailbone/views/auth.py b/tailbone/views/auth.py index 1a1c406d..9bcb644f 100644 --- a/tailbone/views/auth.py +++ b/tailbone/views/auth.py @@ -122,9 +122,14 @@ 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 + # nb. hacky..but necessary, to add the refs, for autofocus + # (also add key handler, so ENTER acts like TAB) dform = form.make_deform_form() - dform['username'].widget.attributes = {'ref': 'username'} + dform['username'].widget.attributes = { + 'ref': 'username', + '@keydown.native': 'usernameKeydown', + } + dform['password'].widget.attributes = {'ref': 'password'} return { 'form': form,