Skip to content

Commit

Permalink
feat(QItem): improve blur target refocusing quasarframework#10510
Browse files Browse the repository at this point in the history
  • Loading branch information
pdanpdan committed Sep 18, 2021
1 parent 4be8ade commit 7d78b6c
Showing 1 changed file with 23 additions and 14 deletions.
37 changes: 23 additions & 14 deletions ui/src/components/item/QItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export default Vue.extend({
onEvents () {
return {
...this.qListeners,
focus: this.__onFocus,
click: this.__onClick,
keyup: this.__onKeyup
}
Expand All @@ -83,22 +84,14 @@ export default Vue.extend({
return child
},

__onFocus (e) {
this.isClickable === true && this.__refocus()
this.qListeners.focus !== void 0 && this.qListeners.focus(e)
},

__onClick (e) {
if (this.isClickable === true) {
if (
this.$q.interaction.isPointer === true &&
this.$refs.blurTarget !== void 0 &&
document.activeElement === this.$el
) {
this.$refs.blurTarget.focus()
}
else if (
this.$q.interaction.isKeyboard === true &&
document.activeElement === this.$refs.blurTarget
) {
this.$el.focus()
}

this.__refocus()
this.$emit('click', e)
}
},
Expand All @@ -113,6 +106,22 @@ export default Vue.extend({
}

this.$emit('keyup', e)
},

__refocus () {
if (
this.$q.interaction.isPointer === true &&
this.$refs.blurTarget !== void 0 &&
document.activeElement === this.$el
) {
this.$refs.blurTarget.focus()
}
else if (
this.$q.interaction.isKeyboard === true &&
document.activeElement === this.$refs.blurTarget
) {
this.$el.focus()
}
}
},

Expand Down

0 comments on commit 7d78b6c

Please sign in to comment.