Skip to content

Commit 4a60a3c

Browse files
authored
Merge pull request #2272 from Akshat55/label-textarea
fix: prioritize input/textarea over div when setting id
2 parents 916b2f2 + 45f4a09 commit 4a60a3c

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/input/label.component.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,16 @@ export class Label implements AfterContentInit, AfterViewInit {
169169
*/
170170
ngAfterViewInit() {
171171
if (this.wrapper) {
172-
const inputElement = this.wrapper.nativeElement.querySelector("input,textarea,div");
172+
// Prioritize setting id to `input` & `textarea` over div
173+
const inputElement = this.wrapper.nativeElement.querySelector("input,textarea");
173174
if (inputElement) {
174175
inputElement.setAttribute("id", this.labelInputID);
176+
return;
177+
}
178+
179+
const divElement = this.wrapper.nativeElement.querySelector("div");
180+
if (divElement) {
181+
divElement.setAttribute("id", this.labelInputID);
175182
}
176183
}
177184
}

0 commit comments

Comments
 (0)