Skip to content

Commit 9dc05fb

Browse files
committed
fix: remove aria-required attribute from DOM when false
1 parent d4c84b1 commit 9dc05fb

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

projects/material/src/lib/mat-dropzone/mat-dropzone.component.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ export class MatDropzone
112112
private _placeholder = '';
113113

114114
@Input()
115-
@HostBinding('attr.aria-required')
116115
get required(): boolean {
117116
const controlRequired = this.ngControl?.control?.hasValidator(Validators.required);
118117
return this._required || controlRequired || false;
@@ -140,6 +139,13 @@ export class MatDropzone
140139
return this.empty && this.required ? null : this.errorState;
141140
}
142141

142+
@HostBinding('attr.aria-required')
143+
get ariaRequired() {
144+
// Accessibility guidelines say that the attribute should be omitted when false,
145+
// so we return null instead of false to remove it from the DOM.
146+
return this.required || null;
147+
}
148+
143149
ngAfterContentInit() {
144150
super.ngAfterContentInit();
145151

0 commit comments

Comments
 (0)