Skip to content

Commit 9b4f435

Browse files
crisbetoandrewseguin
authored andcommitted
fix(select): wrong cursor on disabled select (#7696)
* Fixes some area of a disabled select having a `cursor: pointer`. * Replaces the `mat-disabled` class on the form field underline with a `mat-form-field-disabled` class on the form field itself to allow for easier styling. Fixes #7695.
1 parent e129e3d commit 9b4f435

File tree

6 files changed

+19
-19
lines changed

6 files changed

+19
-19
lines changed

src/lib/form-field/_form-field-theme.scss

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@
5555

5656
.mat-form-field-underline {
5757
background-color: $underline-color;
58+
}
5859

59-
&.mat-disabled {
60-
@include mat-control-disabled-underline($underline-color);
61-
}
60+
.mat-form-field-disabled .mat-form-field-underline {
61+
@include mat-control-disabled-underline($underline-color);
6262
}
6363

6464
.mat-form-field-ripple {

src/lib/form-field/form-field.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@
3535
</div>
3636
</div>
3737

38-
<div class="mat-input-underline mat-form-field-underline" #underline
39-
[class.mat-disabled]="_control.disabled">
38+
<div class="mat-input-underline mat-form-field-underline" #underline>
4039
<span class="mat-input-ripple mat-form-field-ripple"
4140
[class.mat-accent]="color == 'accent'"
4241
[class.mat-warn]="color == 'warn'"></span>

src/lib/form-field/form-field.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ $mat-form-field-underline-height: 1px !default;
148148
// Prevents underline from disappearing at lower zoom levels.
149149
transform: perspective(1px);
150150

151-
&.mat-disabled {
151+
.mat-form-field-disabled & {
152152
background-position: 0;
153153
background-color: transparent;
154154
}

src/lib/form-field/form-field.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ let nextUniqueId = 0;
7575
'[class.mat-form-field-invalid]': '_control.errorState',
7676
'[class.mat-form-field-can-float]': '_canPlaceholderFloat',
7777
'[class.mat-form-field-should-float]': '_control.shouldPlaceholderFloat || _shouldAlwaysFloat',
78+
'[class.mat-form-field-disabled]': '_control.disabled',
7879
'[class.mat-focused]': '_control.focused',
7980
'[class.mat-primary]': 'color == "primary"',
8081
'[class.mat-accent]': 'color == "accent"',

src/lib/input/input.spec.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -423,19 +423,19 @@ describe('MatInput without forms', function () {
423423
const fixture = TestBed.createComponent(MatInputWithDisabled);
424424
fixture.detectChanges();
425425

426-
const underlineEl =
427-
fixture.debugElement.query(By.css('.mat-form-field-underline')).nativeElement;
426+
const formFieldEl =
427+
fixture.debugElement.query(By.css('.mat-form-field')).nativeElement;
428428
const inputEl = fixture.debugElement.query(By.css('input')).nativeElement;
429429

430-
expect(underlineEl.classList.contains('mat-disabled'))
431-
.toBe(false, `Expected underline not to start out disabled.`);
430+
expect(formFieldEl.classList.contains('mat-form-field-disabled'))
431+
.toBe(false, `Expected form field not to start out disabled.`);
432432
expect(inputEl.disabled).toBe(false);
433433

434434
fixture.componentInstance.disabled = true;
435435
fixture.detectChanges();
436436

437-
expect(underlineEl.classList.contains('mat-disabled'))
438-
.toBe(true, `Expected underline to look disabled after property is set.`);
437+
expect(formFieldEl.classList.contains('mat-form-field-disabled'))
438+
.toBe(true, `Expected form field to look disabled after property is set.`);
439439
expect(inputEl.disabled).toBe(true);
440440
}));
441441

@@ -1010,19 +1010,19 @@ describe('MatInput with forms', () => {
10101010
const fixture = TestBed.createComponent(MatInputWithFormControl);
10111011
fixture.detectChanges();
10121012

1013-
const underlineEl =
1014-
fixture.debugElement.query(By.css('.mat-form-field-underline')).nativeElement;
1013+
const formFieldEl =
1014+
fixture.debugElement.query(By.css('.mat-form-field')).nativeElement;
10151015
const inputEl = fixture.debugElement.query(By.css('input')).nativeElement;
10161016

1017-
expect(underlineEl.classList)
1018-
.not.toContain('mat-disabled', `Expected underline not to start out disabled.`);
1017+
expect(formFieldEl.classList)
1018+
.not.toContain('mat-form-field-disabled', `Expected form field not to start out disabled.`);
10191019
expect(inputEl.disabled).toBe(false);
10201020

10211021
fixture.componentInstance.formControl.disable();
10221022
fixture.detectChanges();
10231023

1024-
expect(underlineEl.classList).toContain('mat-disabled',
1025-
`Expected underline to look disabled after disable() is called.`);
1024+
expect(formFieldEl.classList).toContain('mat-form-field-disabled',
1025+
`Expected form field to look disabled after disable() is called.`);
10261026
expect(inputEl.disabled).toBe(true);
10271027
});
10281028

src/lib/select/select.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ $mat-select-placeholder-arrow-space: 2 * ($mat-select-arrow-size + $mat-select-a
7878
}
7979

8080
.mat-form-field-type-mat-select {
81-
.mat-form-field-flex {
81+
&:not(.mat-form-field-disabled) .mat-form-field-flex {
8282
cursor: pointer;
8383
}
8484

0 commit comments

Comments
 (0)