Skip to content

Commit

Permalink
fix: use vnode proprety cant work, fix it was failed when input has b…
Browse files Browse the repository at this point in the history
…een validation
  • Loading branch information
wuls committed Nov 27, 2020
1 parent 89ed24a commit 884d2a3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 29 deletions.
26 changes: 2 additions & 24 deletions packages/message-box/src/MessageBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,11 @@ let msgQueue = []

const defaultCallback = (action) => {
if (currentMsg) {
// const callback = currentMsg.callback
// debugger
// if (typeof callback === 'function') {
// if (instance.component.ctx.showInput) {
// callback(instance.component.ctx.inputValue, action)
// } else {
// callback(action)
// }
// }
if (currentMsg.resolve) {
if (action === 'confirm') {
if (instance.component.vnode.showInput) {
if (instance.component.vnode.props.showInput) {
currentMsg.resolve({
value: instance.component.vnode.state.inputValue,
value: instance.component.setupState.state.inputValue,
action
})
} else {
Expand All @@ -83,16 +74,10 @@ const initInstance = (currentMsg, VNode = null) => {
}

const showNextMsg = () => {
// if (!instance.visible || instance.closeTimer) {
if (msgQueue.length > 0) {
currentMsg = msgQueue.shift()

const options = currentMsg.options
// for (const prop in options) {
// if (Object.hasOwnProperty.call(options, prop)) {
// instance[prop] = options[prop]
// }
// }

if (options.callback === undefined) {
options.callback = defaultCallback
Expand All @@ -101,18 +86,11 @@ const showNextMsg = () => {
const oldCb = options.callback
options.callback = (action, instance) => {
oldCb(action, instance)
// showNextMsg()
}
// if (isVNode(instance.message)) {
// instance.slots.default = [instance.message]
// instance.message = null
// }
if (isVNode(currentMsg.message)) {
initInstance(currentMsg, { default: () => currentMsg.message })
}
// if (!instance) {
initInstance(currentMsg)
// }
;[
'modal',
'showClose',
Expand Down
7 changes: 2 additions & 5 deletions packages/message-box/src/MessageBox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -357,16 +357,13 @@ export default {
}
const confirmButtonLoading = ref(false)
const handleAction = (action) => {
if (
unref(_type) === 'prompt' &&
state.action === 'confirm' &&
!validate()
) {
if (unref(_type) === 'prompt' && action === 'confirm' && !validate()) {
return
}
state.action = action
if (typeof unref(beforeClose) === 'function') {
const close = getSafeClose()
console.log(instance.vnode)
unref(beforeClose)(action, instance.vnode, close)
} else {
doClose()
Expand Down

0 comments on commit 884d2a3

Please sign in to comment.