Skip to content

Commit

Permalink
fix(form-textarea): Set width to 100% if in plaintext mode
Browse files Browse the repository at this point in the history
Maintains the form-control width in `plaintext` mode

Added a `noResize` prop to allow user to stop text area from being resized
  • Loading branch information
tmorehouse committed Sep 2, 2017
1 parent 9db37c4 commit 01735e6
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion lib/components/form-textarea.vue
@@ -1,6 +1,7 @@
<template> <template>
<textarea v-model="localValue" <textarea v-model="localValue"
:class="inputClass" :class="inputClass"
:style="inputStyle"
:id="safeId()" :id="safeId()"
:name="name" :name="name"
:disabled="disabled" :disabled="disabled"
Expand Down Expand Up @@ -61,6 +62,10 @@
// 'soft', 'hard' or 'off'. Browser default is 'soft' // 'soft', 'hard' or 'off'. Browser default is 'soft'
type: String, type: String,
default: 'soft' default: 'soft'
},
noResize: {
type: Boolean,
default: false
} }
}, },
computed: { computed: {
Expand All @@ -76,6 +81,14 @@
this.stateClass this.stateClass
]; ];
}, },
inputStyle() {
// We set width 100% in plaintext mode to get around a shortcoming in bootstrap CSS
// setting noResize to true will disable the ability for the user to resize the textarea
return {
width: this.plaintext ? '100%' : null,
resize: this.noResize ? 'false' : null
};
},
computedAriaInvalid() { computedAriaInvalid() {
if (!Boolean(this.ariaInvalid) || this.ariaInvalid === 'false') { if (!Boolean(this.ariaInvalid) || this.ariaInvalid === 'false') {
// this.ariaInvalid is null or false or 'false' // this.ariaInvalid is null or false or 'false'
Expand All @@ -85,7 +98,7 @@
// User wants explicit aria-invalid=true // User wants explicit aria-invalid=true
return 'true'; return 'true';
} }
// Most likely a string value (which could be 'true') // Most likely a string value (which could be the string 'true')
return this.ariaInvalid; return this.ariaInvalid;
} }
}, },
Expand Down

0 comments on commit 01735e6

Please sign in to comment.