Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

feat(quasar): Add touchPosition processing to QPopupProxy and don't force touchPosition on contextMenu in QMenu #3671

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/src/examples/QPopupProxy/ContextMenu.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<div class="q-pa-md">
<q-btn push color="purple" label="Handles right-click">
<q-popup-proxy context-menu>
<q-popup-proxy touch-position context-menu>
<q-banner>
<template v-slot:avatar>
<q-icon name="signal_wifi_off" color="primary" />
Expand Down
6 changes: 3 additions & 3 deletions quasar/dev/components/components/menu-test.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<div class="row" style="padding: 1500px 0; width: 2000px">
<div class="col" style="height:2000px; width:100px; background-color:red;">
<q-menu context-menu>
<q-menu touch-position context-menu>
<q-list link separator style="min-width: 150px; max-height: 300px;">
<q-item v-close-popup>
<q-item-section>Test</q-item-section>
Expand All @@ -11,7 +11,7 @@
</div>

<div class="col" style="margin-top: 500px; height:2000px; width:100px; background-color:red;">
<q-menu context-menu>
<q-menu touch-position context-menu>
<q-list link separator style="min-width: 150px; max-height: 300px;">
<q-item v-close-popup>
<q-item-section>Test</q-item-section>
Expand All @@ -21,7 +21,7 @@
</div>

<div class="col" style="margin-bottom: 500px; height:2000px; width:100px; background-color:red;">
<q-menu context-menu>
<q-menu touch-position context-menu>
<q-list link separator style="min-width: 150px; max-height: 300px;">
<q-item v-close-popup>
<q-item-section>Test</q-item-section>
Expand Down
35 changes: 35 additions & 0 deletions quasar/dev/components/components/popup-proxy.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,24 @@
</q-popup-proxy>
</div>

<div class="popup-surface-test">
<div>Handles click - touch position</div>

<q-popup-proxy touch-position>
<q-banner>
<q-icon slot="avatar" name="signal_wifi_off" color="primary" />

<input v-model="text">
You have lost connection to the internet. This app is offline.

<q-btn label="Close" v-close-popup />
<div>Popup text.</div>

<q-btn slot="action" flat color="primary" label="close" v-close-popup />
</q-banner>
</q-popup-proxy>
</div>

<div class="popup-surface-test">
<div>Handles right-click (context)</div>

Expand All @@ -34,6 +52,23 @@
</q-popup-proxy>
</div>

<div class="popup-surface-test">
<div>Handles right-click (context) - touch-position</div>

<q-popup-proxy context-menu touch-position>
<q-banner>
<q-icon slot="avatar" name="signal_wifi_off" color="primary" />

<input v-model="text">
You have lost connection to the internet. This app is offline.
<q-btn label="Close" v-close-popup />
<div>Popup text.</div>

<q-btn slot="action" flat color="primary" label="close" v-close-popup />
</q-banner>
</q-popup-proxy>
</div>

<div class="q-mt-xl">
<!-- With QPopupProxy -->
<q-input filled v-model="input" mask="date" :rules="['date']">
Expand Down
6 changes: 4 additions & 2 deletions quasar/src/components/menu/QMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ export default Vue.extend({
},
noParentEvent: Boolean,

touchPositionEvent: {},

touchPosition: Boolean,
persistent: Boolean,
autoClose: Boolean,
Expand Down Expand Up @@ -120,8 +122,8 @@ export default Vue.extend({
this.timer = setTimeout(() => {
const { top, left } = this.anchorEl.getBoundingClientRect()

if (this.touchPosition || this.contextMenu) {
const pos = position(evt)
if (this.touchPosition) {
const pos = position(evt || this.touchPositionEvent)
this.absoluteOffset = { left: pos.left - left, top: pos.top - top }
}
else {
Expand Down
9 changes: 9 additions & 0 deletions quasar/src/components/popup-proxy/QPopupProxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ export default Vue.extend({
default: 450
},

touchPosition: Boolean,

disable: Boolean
},

Expand Down Expand Up @@ -60,6 +62,8 @@ export default Vue.extend({

const breakpoint = parseInt(this.breakpoint, 10)

this.touchPositionEvent = this.touchPosition === true ? evt : void 0

this.showing = true
this.$emit('input', true)

Expand Down Expand Up @@ -104,6 +108,11 @@ export default Vue.extend({
)
) ? { cover: true, maxHeight: '99vh' } : {}

if (this.touchPosition === true && this.touchPositionEvent !== void 0 && this.type === 'menu') {
props.touchPosition = this.touchPosition
props.touchPositionEvent = this.touchPositionEvent
}

const data = {
props: Object.assign(props, this.$attrs, {
value: this.showing
Expand Down
5 changes: 5 additions & 0 deletions quasar/src/components/popup-proxy/QPopupProxy.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
"examples": [ 992, ":breakpoint=\"1024\"" ]
},

"touch-position": {
"type": "Boolean",
"desc": "Allows for the target position to be set by the mouse position, when in menu mode and the target of the menu is either clicked or touched"
},

"disable": {
"extends": "disable"
}
Expand Down