-
Notifications
You must be signed in to change notification settings - Fork 31
fix(InfoTip)!: Remove aria-live and implement focus mgmt #3215
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
base: main
Are you sure you want to change the base?
Conversation
|
View your CI Pipeline Execution ↗ for commit c39d7ac ☁️ Nx Cloud last updated this comment at |
aresnik11
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking really good!! Just a couple of smaller storybook asks
| it('automatically labels InfoTip button by the field label when label is a string', () => { | ||
| const { view } = renderWithInfotip({ infotip: { info } }); | ||
|
|
||
| view.getByRole('button', { name: new RegExp(label) }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need new RegExp here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i initially did it cos optional is added by the field label, but i'll just make it more specific
| fields: [ | ||
| { | ||
| label: 'Email address', | ||
| name: 'email', | ||
| size: 9, | ||
| type: 'email', | ||
| infotip: { | ||
| info: 'We will never share your email with third parties.', | ||
| }, | ||
| }, | ||
| ], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| ## InfoTip | ||
|
|
||
| Any field can include an `infotip` prop to provide additional context to users. | ||
|
|
||
| ### Automatic labelling | ||
|
|
||
| InfoTip buttons are automatically labelled by string field labels for accessibility. | ||
|
|
||
| <Canvas of={FieldsStories.InfoTipAutoLabelling} /> | ||
|
|
||
| ### ReactNode labels | ||
|
|
||
| For ReactNode labels, you have three options: | ||
|
|
||
| - `labelledByFieldLabel: true` - opt into automatic labelling by the field label | ||
| - `ariaLabel` - provide a custom accessible name | ||
| - `ariaLabelledby` - reference another element on the page, such as a section heading | ||
|
|
||
| <Canvas of={FieldsStories.InfoTipWithReactNodeLabel} /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can this go with the other infotip info? thats currently under layout. i trust your judgement on whether to move that to here or move this to there
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good call out - i'll add a link to the layout section since this is a little nitty gritty
| I am some helpful yet concise text that needs more explanation | ||
| </Text> | ||
| <InfoTip | ||
| {...args} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is getting the ariaLabel="More information" prop from args
| > | ||
| <ConnectedFormGroup | ||
| field={{ component: ConnectedInput, type: 'email' }} | ||
| infotip={{ info: 'We will never share your email with third parties.' }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can this be floating? or change the alignment
| </Text> | ||
| <ConnectedFormGroup | ||
| field={{ component: ConnectedInput }} | ||
| infotip={{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i would also prob change the alignment on these so you dont have to scroll to see them open
LinKCoding
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, looks great!
It's much cleaner than the delayed announcement and the duplicate screenreader text.
Works great in VO and the focus control is 🔥
Left some nits, but not blocking and up to you if you'd want to implement.
|
|
||
| ## Custom Accessible Labeling | ||
|
|
||
| Provide either `ariaLabel` or `ariaLabelledby` to ensure screen reader users understand the purpose of the InfoTip button. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: the phrasing here is stronger than the current JSDoc:
Its recommended to provide either
ariaLabelorariaLabelledby.
where "recommended" to me feels a bit more optional.
| export type InfoTipProps = TipBaseProps & { | ||
| alignment?: TipBaseAlignment; | ||
| /** | ||
| * Accessible label for the InfoTip button. Its recommended to provide either `ariaLabel` or `ariaLabelledby`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: "Its" => "It's"
Also nit: Feels appropriate to remove "recommended", but would defer to an a11y expert if there's any opinion there.
| */ | ||
| ariaLabel?: string; | ||
| /** | ||
| * ID of an element that labels the InfoTip button. Its recommended to provide either `ariaLabel` or `ariaLabelledby`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: "Its" => "It's"
Co-authored-by: Kenny Lin <[email protected]>
Co-authored-by: Kenny Lin <[email protected]>
|
📬 Published Alpha Packages: |
|
🚀 Styleguide deploy preview ready! Preview URL: https://696a52b4e613b531088e910a--gamut-preview.netlify.app |

Overview
Adds props to InfoTip for customizing the button's
aria-labelandaria-labelledbyattribute. Also adds automatic focus management - when you open an InfoTip, focus moves to the content container. This removed aria-live since it's no longer needed.PR Checklist
Testing Instructions
Auto-focus + keyboard nav (verify tab order makes sense!):
Floating without links:
Defaultstory withplacement: "floating"Floating with links:
WithLinksOrButtonsstoryInline without links:
Defaultstory (default inline placement)Inline with links:
GridForm + ConnectedForm
Screen reader check:
Finish and do a celebratory dance 🎉
PR Links and Envs