File tree Expand file tree Collapse file tree 4 files changed +32
-1
lines changed Expand file tree Collapse file tree 4 files changed +32
-1
lines changed Original file line number Diff line number Diff line change 11import { browser , by , element } from 'protractor' ;
2+ import { screenshot } from '../screenshot' ;
23
34
45describe ( 'input' , ( ) => {
@@ -53,4 +54,24 @@ describe('input', () => {
5354 expect ( input . getAttribute ( 'value' ) ) . toBe ( 'abc123' ) ;
5455 } ) ;
5556 } ) ;
57+
58+ describe ( 'autosize-textarea' , ( ) => {
59+ beforeEach ( ( ) => browser . get ( '/input' ) ) ;
60+
61+ it ( 'should resize correctly' , ( ) => {
62+ let input = element ( by . id ( 'autosize-text-area' ) ) ;
63+ input . sendKeys ( 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' ) ;
64+ screenshot ( 'autosize multiple rows' ) ;
65+ } ) ;
66+
67+ it ( 'should enfore max rows' , ( ) => {
68+ let input = element ( by . id ( 'autosize-text-area' ) ) ;
69+ input . sendKeys (
70+ 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +
71+ 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +
72+ 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +
73+ 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' ) ;
74+ screenshot ( 'autosize more than max rows' ) ;
75+ } ) ;
76+ } ) ;
5677} ) ;
Original file line number Diff line number Diff line change @@ -394,13 +394,14 @@ <h4>Textarea</h4>
394394 < md-toolbar color ="primary "> Textarea Autosize</ md-toolbar >
395395 < md-card-content >
396396 < h3 > Regular <textarea></ h3 >
397- < textarea mdTextareaAutosize class ="demo-textarea "> </ textarea >
397+ < textarea class ="demo-textarea " mdTextareaAutosize mdAutosizeMaxRows =" 10 "> </ textarea >
398398
399399 < h3 > <textarea> with md-input-container</ h3 >
400400 < div >
401401 < md-input-container >
402402 < textarea mdInput
403403 mdTextareaAutosize
404+ mdAutosizeMaxRows ="10 "
404405 placeholder ="Autosized textarea "> </ textarea >
405406 </ md-input-container >
406407 </ div >
Original file line number Diff line number Diff line change 1414 < textarea mdInput id ="text-area " placeholder ="Enter some text "> </ textarea >
1515 </ md-input-container >
1616 </ p >
17+ < p >
18+ < md-input-container >
19+ < textarea mdInput mdTextareaAutosize mdAutosizeMaxRows ="10 " id ="autosize-text-area "
20+ placeholder ="Enter some text "> </ textarea >
21+ </ md-input-container >
22+ </ p >
1723</ section >
Original file line number Diff line number Diff line change @@ -136,10 +136,13 @@ export class MdTextareaAutosize implements AfterViewInit {
136136 }
137137
138138 // Reset the textarea height to auto in order to shrink back to its default size.
139+ // Also temporarily force overflow:hidden, so scroll bars do not interfere with calculations.
139140 textarea . style . height = 'auto' ;
141+ textarea . style . overflow = 'hidden' ;
140142
141143 // Use the scrollHeight to know how large the textarea *would* be if fit its entire value.
142144 textarea . style . height = `${ textarea . scrollHeight } px` ;
145+ textarea . style . overflow = '' ;
143146
144147 this . _previousValue = textarea . value ;
145148 }
You can’t perform that action at this time.
0 commit comments