3 * @class Ext.layout.component.field.TextArea
4 * @extends Ext.layout.component.field.Field
5 * Layout class for {@link Ext.form.field.TextArea} fields. Handles sizing the textarea field.
7 Ext.define('Ext.layout.component.field.TextArea', {
8 extend: 'Ext.layout.component.field.Text',
9 alias: 'layout.textareafield',
11 type: 'textareafield',
15 * Given the target bodyEl dimensions, adjust them if necessary to return the correct final
16 * size based on the text field's {@link Ext.form.field.Text#grow grow config}. Overrides the
17 * textfield layout's implementation to handle height rather than width.
18 * @param {Number} width The bodyEl width
19 * @param {Number} height The bodyEl height
20 * @return {Array} [inputElWidth, inputElHeight]
22 adjustForGrow: function(width, height) {
26 curWidth, curHeight, calcHeight,
27 result = [width, height];
30 inputEl = owner.inputEl;
31 curWidth = inputEl.getWidth(true); //subtract border/padding to get the available width for the text
32 curHeight = inputEl.getHeight();
34 // Get and normalize the field value for measurement
35 value = inputEl.dom.value || ' ';
36 value += owner.growAppend;
38 // Translate newlines to <br> tags
39 value = value.replace(/\n/g, '<br>');
41 // Find the height that contains the whole text value
42 calcHeight = Ext.util.TextMetrics.measure(inputEl, value, curWidth).height +
43 inputEl.getBorderWidth("tb") + inputEl.getPadding("tb");
47 if (Ext.isNumber(height)) {
48 max = Math.min(max, height);
50 result[1] = Ext.Number.constrain(calcHeight, owner.growMin, max);