Unverified Commit 520de42f authored by niketchandivade's avatar niketchandivade Committed by GitHub

fix: improve form accessibility by associating labels with inputs (#96335)

## Summary

This PR improves the accessibility of the `with-apivideo-upload` example
by associating form labels with their corresponding form controls using
the `htmlFor` attribute.

## Changes

- Added `htmlFor="link"` to the "Play button color" label.
- Added `htmlFor="linkHover"` to the "Buttons hover color" label.
- Added an `id` to the "Hide controls" checkbox and associated its label
using `htmlFor`.

## Why

Associating labels with their corresponding form controls improves
accessibility by:

- Allowing screen readers to correctly announce form labels.
- Enabling users to focus or toggle controls by clicking their labels.
- Following HTML and WCAG best practices for accessible forms.

## Before

- Labels were visually displayed but were not programmatically
associated with their respective inputs.

## After

- Each label is associated with its corresponding form control via
`htmlFor` and `id`, improving accessibility without changing
functionality.

### Testing

- Verified that clicking each label focuses or toggles the associated
control.
- No visual changes.
Co-authored-by: 's avatarMarcos Hernanz <96699542+marcoshernanz@users.noreply.github.com>
parent c87d7423
......@@ -68,7 +68,7 @@ const VideoView: NextPage<IVideoViewProps> = ({
<div className="inputs-container">
<div>
<label>Play button color</label>
<label htmlFor="link">Play button color</label>
<input
id="link"
type="text"
......@@ -78,7 +78,7 @@ const VideoView: NextPage<IVideoViewProps> = ({
/>
</div>
<div>
<label>Buttons hover color</label>
<label htmlFor="linkHover">Buttons hover color</label>
<input
id="linkHover"
type="text"
......@@ -89,13 +89,14 @@ const VideoView: NextPage<IVideoViewProps> = ({
</div>
<div>
<input
id="hideControls"
type="checkbox"
checked={hideControls}
onChange={(e) => {
setHideControls(e.currentTarget.checked);
}}
/>
<label>Hide controls</label>
<label htmlFor="hideControls">Hide controls</label>
</div>
</div>
<ApiVideoPlayer
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment