File tree Expand file tree Collapse file tree 6 files changed +44
-7
lines changed Expand file tree Collapse file tree 6 files changed +44
-7
lines changed Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ let nextUniqueId = 0;
15
15
selector : 'mat-hint' ,
16
16
host : {
17
17
'class' : 'mat-mdc-form-field-hint' ,
18
- '[class.mat-form-field-hint-end]' : 'align == "end"' ,
18
+ '[class.mat-mdc- form-field-hint-end]' : 'align = == "end"' ,
19
19
'[id]' : 'id' ,
20
20
// Remove align attribute to prevent it from interfering with layout.
21
21
'[attr.align]' : 'null' ,
Original file line number Diff line number Diff line change 58
58
box-sizing : border-box ;
59
59
}
60
60
61
+ .mat-mdc-form-field-hint-end {
62
+ order : 1 ;
63
+ }
64
+
61
65
// In order to make it possible for developers to disable animations for form-fields,
62
66
// we only activate the animation styles if animations are not explicitly disabled.
63
67
.mat-mdc-form-field :not (.mat-form-field-no-animations ) {
Original file line number Diff line number Diff line change @@ -538,16 +538,30 @@ describe('MatMdcInput without forms', () => {
538
538
expect ( input . getAttribute ( 'aria-describedby' ) ) . toBe ( 'start end' ) ;
539
539
} ) ) ;
540
540
541
+ it ( 'should set a class on the hint element based on its alignment' , fakeAsync ( ( ) => {
542
+ const fixture = createComponent ( MatInputMultipleHintTestController ) ;
543
+
544
+ fixture . componentInstance . startId = 'start' ;
545
+ fixture . componentInstance . endId = 'end' ;
546
+ fixture . detectChanges ( ) ;
547
+
548
+ const start = fixture . nativeElement . querySelector ( '#start' ) ;
549
+ const end = fixture . nativeElement . querySelector ( '#end' ) ;
550
+
551
+ expect ( start . classList ) . not . toContain ( 'mat-mdc-form-field-hint-end' ) ;
552
+ expect ( end . classList ) . toContain ( 'mat-mdc-form-field-hint-end' ) ;
553
+ } ) ) ;
554
+
541
555
it ( 'sets the aria-describedby when a hintLabel is set, in addition to a mat-hint' ,
542
556
fakeAsync ( ( ) => {
543
557
let fixture = createComponent ( MatInputMultipleHintMixedTestController ) ;
544
558
545
559
fixture . detectChanges ( ) ;
546
560
547
561
let hintLabel = fixture . debugElement . query (
548
- By . css ( '.mat-mdc-form-field-hint:not(.mat-form-field-hint-end)' ) ) ! . nativeElement ;
562
+ By . css ( '.mat-mdc-form-field-hint:not(.mat-mdc- form-field-hint-end)' ) ) ! . nativeElement ;
549
563
let endLabel = fixture . debugElement
550
- . query ( By . css ( '.mat-mdc-form-field-hint.mat-form-field-hint-end' ) ) ! . nativeElement ;
564
+ . query ( By . css ( '.mat-mdc-form-field-hint.mat-mdc- form-field-hint-end' ) ) ! . nativeElement ;
551
565
let input = fixture . debugElement . query ( By . css ( 'input' ) ) ! . nativeElement ;
552
566
let ariaValue = input . getAttribute ( 'aria-describedby' ) ;
553
567
Original file line number Diff line number Diff line change @@ -230,6 +230,10 @@ $mat-form-field-default-infix-width: 180px !default;
230
230
position : relative ;
231
231
}
232
232
233
+ .mat-form-field-hint-end {
234
+ order : 1 ;
235
+ }
236
+
233
237
.mat-form-field._mat-animation-noopable {
234
238
.mat-form-field-label ,
235
239
.mat-form-field-ripple {
Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ export const _MAT_HINT = new InjectionToken<MatHint>('MatHint');
25
25
selector : 'mat-hint' ,
26
26
host : {
27
27
'class' : 'mat-hint' ,
28
- '[class.mat-right ]' : 'align == "end"' ,
28
+ '[class.mat-form-field-hint-end ]' : 'align = == "end"' ,
29
29
'[attr.id]' : 'id' ,
30
30
// Remove align attribute to prevent it from interfering with layout.
31
31
'[attr.align]' : 'null' ,
Original file line number Diff line number Diff line change @@ -628,15 +628,30 @@ describe('MatInput without forms', () => {
628
628
expect ( input . getAttribute ( 'aria-describedby' ) ) . toBe ( 'start end' ) ;
629
629
} ) ) ;
630
630
631
+ it ( 'should set a class on the hint element based on its alignment' , fakeAsync ( ( ) => {
632
+ const fixture = createComponent ( MatInputMultipleHintTestController ) ;
633
+
634
+ fixture . componentInstance . startId = 'start' ;
635
+ fixture . componentInstance . endId = 'end' ;
636
+ fixture . detectChanges ( ) ;
637
+
638
+ const start = fixture . nativeElement . querySelector ( '#start' ) ;
639
+ const end = fixture . nativeElement . querySelector ( '#end' ) ;
640
+
641
+ expect ( start . classList ) . not . toContain ( 'mat-form-field-hint-end' ) ;
642
+ expect ( end . classList ) . toContain ( 'mat-form-field-hint-end' ) ;
643
+ } ) ) ;
644
+
631
645
it ( 'sets the aria-describedby when a hintLabel is set, in addition to a mat-hint' ,
632
646
fakeAsync ( ( ) => {
633
647
let fixture = createComponent ( MatInputMultipleHintMixedTestController ) ;
634
648
635
649
fixture . detectChanges ( ) ;
636
650
637
- let hintLabel =
638
- fixture . debugElement . query ( By . css ( '.mat-hint:not(.mat-right)' ) ) ! . nativeElement ;
639
- let endLabel = fixture . debugElement . query ( By . css ( '.mat-hint.mat-right' ) ) ! . nativeElement ;
651
+ let hintLabel = fixture . debugElement
652
+ . query ( By . css ( '.mat-hint:not(.mat-form-field-hint-end)' ) ) ! . nativeElement ;
653
+ let endLabel = fixture . debugElement
654
+ . query ( By . css ( '.mat-hint.mat-form-field-hint-end' ) ) ! . nativeElement ;
640
655
let input = fixture . debugElement . query ( By . css ( 'input' ) ) ! . nativeElement ;
641
656
let ariaValue = input . getAttribute ( 'aria-describedby' ) ;
642
657
You can’t perform that action at this time.
0 commit comments