Skip to content

Commit

Permalink
Fix: Associate labels with input fields of File and Checkbox Widget
Browse files Browse the repository at this point in the history
  • Loading branch information
Abhishek-17h committed Jan 15, 2025
1 parent 6f6f98f commit 6bd7de3
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/volto/news/6341.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The input fields in FileWidget and CheckboxWidget are now programmatically associated with their labels, improving accessibility. Previously, the labels were not linked to their corresponding input fields. @Abhishek-17h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const CheckboxWidget = (props) => {
<FormFieldWrapper {...props} columns={1}>
<div className="wrapper">
<Checkbox
id={`field-${id}`}
name={`field-${id}`}
checked={value || false}
disabled={isDisabled}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ const FileWidget = (props) => {
</div>
)}

<label className="label-file-widget-input">
<label htmlFor={`field-${id}`} className="label-file-widget-input">
{value
? intl.formatMessage(messages.replaceFile)
: intl.formatMessage(messages.addNewFile)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ exports[`CheckboxWidget renders a checkbox widget component 1`] = `
>
<input
class="hidden"
id="field-my-field"
name="field-my-field"
readonly=""
tabindex="0"
Expand Down Expand Up @@ -65,6 +66,7 @@ exports[`CheckboxWidget renders a checkbox widget component checked 1`] = `
<input
checked=""
class="hidden"
id="field-my-field"
name="field-my-field"
readonly=""
tabindex="0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ exports[`FileWidget renders a file widget component with value 1`] = `
/>
<label
class="label-file-widget-input"
for="field-my-field"
>
Replace existing file
</label>
Expand Down Expand Up @@ -122,6 +123,7 @@ exports[`FileWidget renders a file widget component with value in raw data 1`] =
/>
<label
class="label-file-widget-input"
for="field-my-field"
>
Replace existing file
</label>
Expand Down Expand Up @@ -208,6 +210,7 @@ exports[`FileWidget renders an empty file widget component 1`] = `
</div>
<label
class="label-file-widget-input"
for="field-my-field"
>
Choose a file
</label>
Expand Down

0 comments on commit 6bd7de3

Please sign in to comment.