Browse Source

remove errorMessage when prompt is closed

Leopoldthecoder 8 years ago
parent
commit
4ac3118687
3 changed files with 10 additions and 4 deletions
  1. 2 0
      CHANGELOG.md
  2. 1 1
      examples/docs/zh-cn/message-box.md
  3. 7 3
      packages/message-box/src/main.vue

+ 2 - 0
CHANGELOG.md

@@ -5,6 +5,8 @@
 *2016-XX-XX*
 
 - 修复 Form reset method 对日期控件不起效的问题
+- 修复 Dialog 和 Message Box 在 body 无溢出时错误地添加 padding-right 的问题
+- 修复 Message Box 的 prompt 在打开时会携带之前的验证状态的问题
 
 #### 非兼容性更新
 

+ 1 - 1
examples/docs/zh-cn/message-box.md

@@ -143,7 +143,7 @@
         this.$prompt('请输入邮箱', '提示', {
           inputPattern: /[\w!#$%&'*+/=?^_`{|}~-]+(?:\.[\w!#$%&'*+/=?^_`{|}~-]+)*@(?:[\w](?:[\w-]*[\w])?\.)+[\w](?:[\w-]*[\w])?/,
           inputErrorMessage: '邮箱格式不正确'
-        }).then(value => {
+        }).then(({ value }) => {
           this.$message({
             type: 'success',
             message: '你的邮箱是: ' + value

+ 7 - 3
packages/message-box/src/main.vue

@@ -140,19 +140,23 @@
     },
 
     watch: {
-      inputValue() {
-        if (this.$type === 'prompt') {
+      inputValue(val) {
+        if (this.$type === 'prompt' && val !== null) {
           this.validate();
         }
       },
 
       value(val) {
-        if (val && this.$type === 'prompt') {
+        if (this.$type !== 'prompt') return;
+        if (val) {
           setTimeout(() => {
             if (this.$refs.input && this.$refs.input.$el) {
               this.$refs.input.$el.querySelector('input').focus();
             }
           }, 500);
+        } else {
+          this.editorErrorMessage = '';
+          removeClass(this.$refs.input.$el.querySelector('input'), 'invalid');
         }
       }
     },