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 input forms accessibility violations #7059

Open
wants to merge 3 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
13 changes: 9 additions & 4 deletions src/js/components/Form/stories/ControlledInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const ControlledInput = () => {
const [ampm, setAmpm] = useState('');
const [size, setSize] = useState('');
const [comments, setComments] = useState('');
const [age, setAge] = useState('');
const [age, setAge] = useState(0);
return (
// Uncomment <Grommet> lines when using outside of storybook
// <Grommet theme={...}>
Expand All @@ -46,6 +46,7 @@ export const ControlledInput = () => {
<TextInput
id="name"
name="name"
aria-label="name"
value={name}
onChange={(event) => setName(event.target.value)}
/>
Expand All @@ -54,6 +55,7 @@ export const ControlledInput = () => {
<MaskedInput
id="email"
name="email"
aria-label="email"
mask={[
{ regexp: /^[\w\-_.]+$/, placeholder: 'example' },
{ fixed: '@' },
Expand All @@ -69,13 +71,15 @@ export const ControlledInput = () => {
<CheckBox
name="subscribe"
label="Subscribe?"
aria-label="subscribe"
checked={subscribe}
onChange={(event) => setSubscribe(event.target.checked)}
/>
</FormField>
<FormField name="ampm">
<RadioButtonGroup
name="ampm"
aria-label="select your preferred time"
options={['morning', 'evening']}
value={ampm}
onChange={(event) => setAmpm(event.target.value)}
Expand All @@ -95,6 +99,7 @@ export const ControlledInput = () => {
<TextArea
id="comments"
name="comments"
aria-label="comments"
value={comments}
onChange={(event) => setComments(event.target.value)}
/>
Expand All @@ -110,9 +115,9 @@ export const ControlledInput = () => {
/>
</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