Fix login "enter" key behavior, per oruga
This commit is contained in:
parent
e4c4259674
commit
3d319cbd09
|
@ -60,11 +60,19 @@
|
|||
<%def name="modify_this_page_vars()">
|
||||
<script type="text/javascript">
|
||||
|
||||
TailboneForm.mounted = function() {
|
||||
${form.component_studly}Data.usernameInput = null
|
||||
|
||||
${form.component_studly}.mounted = function() {
|
||||
this.$refs.username.focus()
|
||||
this.usernameInput = this.$refs.username.$el.querySelector('input')
|
||||
this.usernameInput.addEventListener('keydown', this.usernameKeydown)
|
||||
}
|
||||
|
||||
TailboneForm.methods.usernameKeydown = function(event) {
|
||||
${form.component_studly}.beforeDestroy = function() {
|
||||
this.usernameInput.removeEventListener('keydown', this.usernameKeydown)
|
||||
}
|
||||
|
||||
${form.component_studly}.methods.usernameKeydown = function(event) {
|
||||
if (event.which == 13) {
|
||||
event.preventDefault()
|
||||
this.$refs.password.focus()
|
||||
|
|
|
@ -331,7 +331,7 @@
|
|||
:disabled="disabled"
|
||||
v-model="buefyValue"
|
||||
@update:modelValue="val => $emit('update:modelValue', val)"
|
||||
autocomplete="off"
|
||||
:autocomplete="autocomplete"
|
||||
ref="input">
|
||||
<slot />
|
||||
</o-input>
|
||||
|
@ -342,6 +342,7 @@
|
|||
props: {
|
||||
modelValue: null,
|
||||
type: String,
|
||||
autocomplete: String,
|
||||
disabled: Boolean,
|
||||
},
|
||||
data() {
|
||||
|
@ -359,8 +360,10 @@
|
|||
methods: {
|
||||
focus() {
|
||||
if (this.type == 'textarea') {
|
||||
// TODO: this does not work right
|
||||
// TODO: this does not always work right?
|
||||
this.$refs.input.$el.querySelector('textarea').focus()
|
||||
} else {
|
||||
this.$refs.input.$el.querySelector('input').focus()
|
||||
}
|
||||
},
|
||||
},
|
||||
|
|
|
@ -125,7 +125,7 @@ class AuthenticationView(View):
|
|||
dform = form.make_deform_form()
|
||||
dform['username'].widget.attributes = {
|
||||
'ref': 'username',
|
||||
'@keydown.native': 'usernameKeydown',
|
||||
'autocomplete': 'off',
|
||||
}
|
||||
dform['password'].widget.attributes = {'ref': 'password'}
|
||||
|
||||
|
|
Loading…
Reference in a new issue