MessageBox: add distinguishCancelAndClose (#11831)

This commit is contained in:
杨奕
2018-07-03 12:02:21 +08:00
committed by hetech
parent b799d2ec4d
commit 5ef3d0ec8d
7 changed files with 239 additions and 24 deletions

View File

@@ -29,7 +29,8 @@ const defaults = {
beforeClose: null,
dangerouslyUseHTMLString: false,
center: false,
roundButton: false
roundButton: false,
distinguishCancelAndClose: false
};
import Vue from 'vue';
@@ -59,7 +60,7 @@ const defaultCallback = action => {
} else {
currentMsg.resolve(action);
}
} else if (action === 'cancel' && currentMsg.reject) {
} else if (currentMsg.reject && (action === 'cancel' || action === 'close')) {
currentMsg.reject(action);
}
}

View File

@@ -22,8 +22,8 @@
class="el-message-box__headerbtn"
aria-label="Close"
v-if="showClose"
@click="handleAction('cancel')"
@keydown.enter="handleAction('cancel')">
@click="handleAction(distinguishCancelAndClose ? 'close' : 'cancel')"
@keydown.enter="handleAction(distinguishCancelAndClose ? 'close' : 'cancel')">
<i class="el-message-box__close el-icon-close"></i>
</button>
</div>
@@ -173,7 +173,7 @@
handleWrapperClick() {
if (this.closeOnClickModal) {
this.handleAction('cancel');
this.handleAction(this.distinguishCancelAndClose ? 'close' : 'cancel');
}
},
@@ -319,7 +319,8 @@
callback: null,
dangerouslyUseHTMLString: false,
focusAfterClosed: null,
isOnComposition: false
isOnComposition: false,
distinguishCancelAndClose: false
};
}
};