Skip to content

Commit 0de50cc

Browse files
pdanpdanrstoenescu
authored andcommitted
fix(anchor-mixin): Add cleanup events for context menu quasarframework#5638 (quasarframework#5640)
1 parent 4417682 commit 0de50cc

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

ui/src/mixins/anchor.js

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { clearSelection } from '../utils/selection.js'
22
import { prevent } from '../utils/event.js'
3-
import { addEvt, cleanEvt } from '../utils/touch.js'
3+
import { addEvt, cleanEvt, getTouchTarget } from '../utils/touch.js'
44

55
export default {
66
props: {
@@ -66,12 +66,19 @@ export default {
6666
}
6767
},
6868

69-
__mobileTouch (evt) {
69+
__mobileCleanup (evt) {
70+
this.anchorEl.classList.remove('non-selectable')
7071
clearTimeout(this.touchTimer)
7172

7273
if (this.showing === true && evt !== void 0) {
7374
clearSelection()
7475
}
76+
},
77+
78+
__mobilePrevent: prevent,
79+
80+
__mobileTouch (evt) {
81+
this.__mobileCleanup(evt)
7582

7683
if (this.__showCondition(evt) !== true) {
7784
return
@@ -80,9 +87,16 @@ export default {
8087
this.hide(evt)
8188
this.anchorEl.classList.add('non-selectable')
8289

90+
const target = getTouchTarget(evt.target)
91+
addEvt(this, 'anchor', [
92+
[ target, 'touchmove', '__mobileCleanup', 'passive' ],
93+
[ target, 'touchend', '__mobileCleanup', 'passive' ],
94+
[ target, 'touchcancel', '__mobileCleanup', 'passive' ],
95+
[ this.anchorEl, 'contextmenu', '__mobilePrevent', 'notPassive' ]
96+
])
97+
8398
this.touchTimer = setTimeout(() => {
8499
this.show(evt)
85-
this.anchorEl.classList.remove('non-selectable')
86100
}, 300)
87101
},
88102

0 commit comments

Comments
 (0)