Skip to content

fix(form-field): remove leading space for asterisk #12727

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

Closed
Closed
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">*</span>
</label>
</span>
</div>
Expand Down
8 changes: 4 additions & 4 deletions src/lib/input/input.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,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!.trim()).toBe('hello*');
}));

it('should hide the required star if input is disabled', () => {
Expand All @@ -404,7 +404,7 @@ describe('MatInput without forms', () => {
const el = fixture.debugElement.query(By.css('label'));

expect(el).not.toBeNull();
expect(el.nativeElement.textContent!.trim()).toMatch(/^hello$/);
expect(el.nativeElement.textContent!.trim()).toBe('hello');
});

it('should hide the required star from screen readers', fakeAsync(() => {
Expand All @@ -422,12 +422,12 @@ 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!.trim()).toBe('hello*');

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

expect(el.nativeElement.textContent).toMatch(/hello/g);
expect(el.nativeElement.textContent!.trim()).toBe('hello');
}));

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