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 Oct 30, 2021
1 parent 9a97bb2 commit e465406
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 e465406

Please sign in to comment.