Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(form-field): remove nonbreaking space before * for required fields #15490

Merged
merged 1 commit into from
Apr 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/lib/form-field/form-field.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
<span
class="mat-placeholder-required mat-form-field-required-marker"
aria-hidden="true"
*ngIf="!hideRequiredMarker && _control.required && !_control.disabled">&nbsp;*</span>
*ngIf="!hideRequiredMarker && _control.required && !_control.disabled">&#32;*</span>
</label>
</span>
</div>
Expand Down
6 changes: 4 additions & 2 deletions src/lib/input/input.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ describe('MatInput without forms', () => {

let el = fixture.debugElement.query(By.css('label'));
expect(el).not.toBeNull();
expect(el.nativeElement.textContent).toMatch(/hello\s+\*/g);
expect(el.nativeElement.textContent).toMatch(/hello +\*/g);
}));

it('should hide the required star if input is disabled', () => {
Expand All @@ -407,6 +407,7 @@ describe('MatInput without forms', () => {

expect(el).not.toBeNull();
expect(el.nativeElement.textContent!.trim()).toMatch(/^hello$/);
expect(el.nativeElement.textContent).not.toMatch(/\*/g);
});

it('should hide the required star from screen readers', fakeAsync(() => {
Expand All @@ -424,12 +425,13 @@ describe('MatInput without forms', () => {

let el = fixture.debugElement.query(By.css('label'));
expect(el).not.toBeNull();
expect(el.nativeElement.textContent).toMatch(/hello\s+\*/g);
expect(el.nativeElement.textContent).toMatch(/hello +\*/g);

fixture.componentInstance.hideRequiredMarker = true;
fixture.detectChanges();

expect(el.nativeElement.textContent).toMatch(/hello/g);
expect(el.nativeElement.textContent).not.toMatch(/\*/g);
}));

it('supports the disabled attribute as binding', fakeAsync(() => {
Expand Down