Skip to content

Commit 6deb3bf

Browse files
palbizuPatricio Albizu
andauthored
feat: adding rows count to textarea (#785)
* feat: adding rows count to textarea * feat: adding UT * feat: Removing log * feat: fixing textarea index * feat: renaming variable * feat: fix test * feat: fixing default rows * feat: adding minHeight feature * feat: textarea minHeight refactoring * feat: fixing label in UT Co-authored-by: Patricio Albizu <[email protected]>
1 parent 55bc7d4 commit 6deb3bf

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

projects/components/src/textarea/textarea.component.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
display: block;
77
height: 100%;
88
width: 100%;
9+
min-height: inherit;
910
}
1011

1112
&.mat-focused {
@@ -21,18 +22,21 @@
2122
.mat-form-field-infix {
2223
height: inherit;
2324
width: inherit;
25+
min-height: inherit;
2426
border: unset;
2527
padding: 0 0 0 8px;
2628
}
2729

2830
.mat-form-field-flex {
2931
height: inherit;
3032
width: inherit;
33+
min-height: inherit;
3134
}
3235

3336
.mat-form-field-wrapper {
3437
height: inherit;
3538
width: inherit;
39+
min-height: inherit;
3640
padding-bottom: 0;
3741

3842
.mat-form-field-label {
@@ -45,6 +49,7 @@
4549
.mat-input-element {
4650
height: inherit;
4751
width: inherit;
52+
min-height: inherit;
4853
margin: 0;
4954

5055
&:after {

projects/components/src/textarea/textarea.component.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,17 @@ describe('Textarea Component', () => {
4545

4646
expect(disabled).toBe('true');
4747
});
48+
49+
test('should match the rows with the number of rows in the textarea', () => {
50+
const rows = 10;
51+
52+
spectator = createHost(`<ht-textarea [placeholder]="placeholder" [rows]="rows"></ht-textarea>`, {
53+
hostProps: {
54+
placeholder: 'TEST',
55+
rows: rows
56+
}
57+
});
58+
59+
expect((spectator.query('.textarea') as HTMLTextAreaElement).rows).toBe(rows);
60+
});
4861
});

projects/components/src/textarea/textarea.component.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { LoggerService } from '@hypertrace/common';
1010
<textarea
1111
class="textarea"
1212
matInput
13+
[rows]="this.rows"
1314
[disabled]="this.disabled"
1415
[placeholder]="this.placeholder"
1516
[ngModel]="this.value"
@@ -29,6 +30,9 @@ export class TextareaComponent implements OnInit {
2930
@Input()
3031
public disabled: boolean | undefined;
3132

33+
@Input()
34+
public rows: number = 2;
35+
3236
@Output()
3337
public readonly valueChange: EventEmitter<string> = new EventEmitter();
3438

0 commit comments

Comments
 (0)