Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: controlled forms accessibility violations #7058

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
38 changes: 29 additions & 9 deletions src/js/components/Form/stories/Controlled.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const defaultValue = {
ampm: '',
size: '',
comments: '',
age: '',
age: 0,
};

const suggestions = ['Shimi', 'Eric'];
Expand All @@ -45,10 +45,16 @@ export const Controlled = () => {
}
>
<FormField label="Name" htmlFor="name" name="name">
<TextInput id="name" name="name" suggestions={suggestions} />
<TextInput
aria-label="name"
id="name"
name="name"
suggestions={suggestions}
/>
</FormField>
<FormField label="Email" htmlFor="email" name="email" required>
<MaskedInput
aria-label="email"
id="email"
name="email"
mask={[
Expand All @@ -61,10 +67,18 @@ export const Controlled = () => {
/>
</FormField>
<FormField name="subscribe">
<CheckBox name="subscribe" label="Subscribe?" />
<CheckBox
aria-label="subscribe"
name="subscribe"
label="Subscribe?"
/>
</FormField>
<FormField name="ampm">
<RadioButtonGroup name="ampm" options={['morning', 'evening']} />
<RadioButtonGroup
aria-label="select your preferred time"
name="ampm"
options={['morning', 'evening']}
/>
</FormField>
<FormField label="Size" htmlFor="size" name="size">
<Select
Expand All @@ -75,15 +89,21 @@ export const Controlled = () => {
/>
</FormField>
<FormField label="Comments" htmlFor="comments" name="comments">
<TextArea id="comments" name="comments" />
<TextArea aria-label="comments" id="comments" name="comments" />
</FormField>
<FormField label="Age" htmlFor="age" name="age" pad>
<RangeInput id="age" name="age" min={15} max={75} />
<RangeInput
aria-label="age"
id="age"
name="age"
min={15}
max={75}
/>
</FormField>
<Box direction="row" justify="between" margin={{ top: 'medium' }}>
<Button label="Cancel" />
<Button type="reset" label="Reset" />
<Button type="submit" label="Update" primary />
<Button aria-label="cancel" label="Cancel" />
<Button aria-label="reset" type="reset" label="Reset" />
<Button aria-label="submit" type="submit" label="Update" primary />
</Box>
</Form>
</Box>
Expand Down