Permalink
Browse files

fix(form-textarea): monitor localValue instead of value when calculat…

…ing lines
  • Loading branch information...
tmorehouse committed Nov 16, 2017
1 parent 1457b5f commit 9f3439f870f8281536d27eb86a9933813a31e25b
Showing with 6 additions and 2 deletions.
  1. +6 −2 src/components/form-textarea/form-textarea.js
@@ -10,7 +10,9 @@ export default {
ref: 'input',
class: t.inputClass,
style: t.inputStyle,
domProps: { value: t.localValue },
directives: [
{ name: 'model', rawName: 'v-model', value: t.localValue, expression: 'localValue' }
],
attrs: {
id: t.safeId(),
name: t.name,
@@ -80,9 +82,11 @@ export default {
},
computed: {
rowsCount() {
// A better option could be based on https://codepen.io/vsync/pen/frudD
// As linebreaks aren't added until the input is submitted
const rows = parseInt(this.rows, 10) || 1;
const maxRows = parseInt(this.maxRows, 10) || 0;
const lines = (this.value || '').toString().split('\n').length;
const lines = (this.localValue || '').toString().split('\n').length;
return maxRows ? Math.min(maxRows, Math.max(rows, lines)) : Math.max(rows, lines);
},
inputClass() {

0 comments on commit 9f3439f

Please sign in to comment.