Skip to content

Commit

Permalink
fix: label for attribute should be only for form elements
Browse files Browse the repository at this point in the history
  • Loading branch information
logaretm committed Feb 22, 2025
1 parent 71873de commit b2b5297
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/five-planes-teach.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@formwerk/core': patch
---

fix: label "for" attribute should be only for form elements
2 changes: 1 addition & 1 deletion packages/core/src/a11y/useLabel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export function useLabel(props: LabelProps) {
return {
ref: refCapture,
id: `${toValue(props.for)}-l`,
for: isLabelElement(labelRef.value) ? toValue(props.for) : undefined,
for: isLabelElement(labelRef.value) && isInputElement(toValue(props.targetRef)) ? toValue(props.for) : undefined,
onClick: props.handleClick || undefined,
} as AriaLabelProps;
});
Expand Down

0 comments on commit b2b5297

Please sign in to comment.