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()">
|
<%def name="modify_this_page_vars()">
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
||||||
TailboneForm.mounted = function() {
|
${form.component_studly}Data.usernameInput = null
|
||||||
|
|
||||||
|
${form.component_studly}.mounted = function() {
|
||||||
this.$refs.username.focus()
|
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) {
|
if (event.which == 13) {
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
this.$refs.password.focus()
|
this.$refs.password.focus()
|
||||||
|
|
|
@ -331,7 +331,7 @@
|
||||||
:disabled="disabled"
|
:disabled="disabled"
|
||||||
v-model="buefyValue"
|
v-model="buefyValue"
|
||||||
@update:modelValue="val => $emit('update:modelValue', val)"
|
@update:modelValue="val => $emit('update:modelValue', val)"
|
||||||
autocomplete="off"
|
:autocomplete="autocomplete"
|
||||||
ref="input">
|
ref="input">
|
||||||
<slot />
|
<slot />
|
||||||
</o-input>
|
</o-input>
|
||||||
|
@ -342,6 +342,7 @@
|
||||||
props: {
|
props: {
|
||||||
modelValue: null,
|
modelValue: null,
|
||||||
type: String,
|
type: String,
|
||||||
|
autocomplete: String,
|
||||||
disabled: Boolean,
|
disabled: Boolean,
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
|
@ -359,8 +360,10 @@
|
||||||
methods: {
|
methods: {
|
||||||
focus() {
|
focus() {
|
||||||
if (this.type == 'textarea') {
|
if (this.type == 'textarea') {
|
||||||
// TODO: this does not work right
|
// TODO: this does not always work right?
|
||||||
this.$refs.input.$el.querySelector('textarea').focus()
|
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 = form.make_deform_form()
|
||||||
dform['username'].widget.attributes = {
|
dform['username'].widget.attributes = {
|
||||||
'ref': 'username',
|
'ref': 'username',
|
||||||
'@keydown.native': 'usernameKeydown',
|
'autocomplete': 'off',
|
||||||
}
|
}
|
||||||
dform['password'].widget.attributes = {'ref': 'password'}
|
dform['password'].widget.attributes = {'ref': 'password'}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue