Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

fix: click-event in draggable modal not triggered on mobile device #808

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
10 changes: 7 additions & 3 deletions src/components/Modal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
<script>
import Resizer from './Resizer.vue'
import {
isInput,
isInputOrClickable,
inRange,
getTouchEvent,
blurActiveElement,
Expand Down Expand Up @@ -190,7 +190,11 @@ export default {
validator(value) {
return value >= 0 && value <= 1
}
}
},
undraggableElement: {
type: [Array],
default: () => []
},
},
components: {
Resizer
Expand Down Expand Up @@ -770,7 +774,7 @@ export default {
const handleDraggableMousedown = event => {
let target = event.target

if (isInput(target)) {
if (isInputOrClickable(target, this.undraggableElement)) {
return
}

Expand Down
6 changes: 3 additions & 3 deletions src/utils/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export * from './numbers'

const INPUT_NODE_NAMES = ['INPUT', 'TEXTAREA', 'SELECT']
const INPUT_OR_CLICKABLE_NODE_NAMES = ['INPUT', 'TEXTAREA', 'SELECT', "BUTTON", "SPAN"]

export const generateId = ((index = 0) => () => (index++).toString())()
/**
Expand Down Expand Up @@ -59,8 +59,8 @@ export const stringStylesToObject = styles => {
}, {})
}

export const isInput = element => {
return element && INPUT_NODE_NAMES.indexOf(element.nodeName) !== -1
export const isInputOrClickable = (element, dynamicElement = []) => {
return element && (INPUT_OR_CLICKABLE_NODE_NAMES.indexOf(element.nodeName) !== -1 || dynamicElement.indexOf(element.nodeName) !== -1)
}

export const getTouchEvent = event => {
Expand Down