Skip to content

Commit ccf5cd3

Browse files
pdanpdanrstoenescu
andauthored
feat(QDialog): don't close modal when mouse clicking on backdrop if a menu is open (make it work the same way as with touch) (quasarframework#8045)
* feat(QDialog): don't close modal when mouse clicking on backdrop if a menu is open (make it work the same way as with touch) * Update event.js * Update event.js Co-authored-by: Razvan Stoenescu <razvan.stoenescu@gmail.com>
1 parent 6d26648 commit ccf5cd3

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

ui/src/components/menu/QMenu.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import AttrsMixin from '../../mixins/attrs.js'
99

1010
import ClickOutside from './ClickOutside.js'
1111
import { getScrollTarget } from '../../utils/scroll.js'
12-
import { create, stop, position, stopAndPrevent } from '../../utils/event.js'
12+
import { create, stop, position, stopAndPreventClick } from '../../utils/event.js'
1313
import EscapeKey from '../../utils/escape-key.js'
1414

1515
import { slot } from '../../utils/slot.js'
@@ -304,7 +304,7 @@ export default Vue.extend({
304304
// prevent click if it's on a dialog backdrop
305305
targetClassList.contains('q-dialog__backdrop')
306306
) {
307-
stopAndPrevent(e)
307+
stopAndPreventClick(e)
308308
}
309309
return true
310310
}

ui/src/utils/event.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,19 @@ export function stopAndPrevent (e) {
110110
e.stopPropagation()
111111
}
112112

113+
export function stopAndPreventClick (evt) {
114+
stopAndPrevent(evt)
115+
116+
if (evt.type === 'mousedown') {
117+
const handler = e => {
118+
e.target === evt.target && stopAndPrevent(e)
119+
document.removeEventListener('click', handler, listenOpts.notPassiveCapture)
120+
}
121+
122+
document.addEventListener('click', handler, listenOpts.notPassiveCapture)
123+
}
124+
}
125+
113126
export function preventDraggable (el, status) {
114127
if (el === void 0 || (status === true && el.__dragPrevented === true)) {
115128
return

0 commit comments

Comments
 (0)