Skip to content

Commit

Permalink
fix: field 计算autosize,需要nextTick (#78)
Browse files Browse the repository at this point in the history
* textarea sizeAdjust 需要nextTick

* fix field unit test
  • Loading branch information
pangxie1991 committed Aug 18, 2017
1 parent a3ce58e commit 97c54d7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion packages/field/src/field.vue
Expand Up @@ -101,7 +101,9 @@ export default {
},
currentValue(val) {
if (this.autosize && this.type === 'textarea') this.sizeAdjust();
if (this.autosize && this.type === 'textarea') {
this.$nextTick(() => this.sizeAdjust());
}
this.$emit('input', val);
}
},
Expand Down
4 changes: 2 additions & 2 deletions test/unit/specs/field.spec.js
Expand Up @@ -120,10 +120,10 @@ describe('Field', () => {
textarea.trigger('input');

wrapper.update();
wrapper.vm.$nextTick(() => {
setTimeout(() => {
expect(wrapper.data().currentValue).to.equal('test');
expect(textareaElement.style.height).to.equal((textareaElement.scrollHeight - textAreaDiff) + 'px');
done();
});
}, 500);
});
});

0 comments on commit 97c54d7

Please sign in to comment.