Skip to content

Commit

Permalink
fix: combobox label for attribute binding
Browse files Browse the repository at this point in the history
  • Loading branch information
logaretm committed Feb 22, 2025
1 parent d34984c commit 04fb9d7
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/cold-pots-crash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@formwerk/core': patch
---

fix: combobox label for attribute binding
18 changes: 13 additions & 5 deletions packages/core/src/a11y/useLabel.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,21 @@ describe('label element', () => {
const labelFor = 'input';

await render({
setup: () =>
useLabel({
for: labelFor,
label: label,
}),
setup: () => {
const inputRef = ref<HTMLElement>();

return {
inputRef,
...useLabel({
for: labelFor,
label: label,
targetRef: inputRef,
}),
};
},
template: `
<label data-testid="label" v-bind="labelProps">Label</label>
<input data-testid="input" ref="inputRef" />
`,
});

Expand Down
1 change: 1 addition & 0 deletions packages/core/src/useComboBox/useComboBox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ export function useComboBox<TOption, TValue = TOption>(
const { labelProps, labelledByProps } = useLabel({
label: props.label,
for: inputId,
targetRef: inputEl,
});

const { validityDetails } = useInputValidity({ field, inputEl, disableHtmlValidation: props.disableHtmlValidation });
Expand Down

0 comments on commit 04fb9d7

Please sign in to comment.