Skip to content

Conversation

@dreamwasp
Copy link
Contributor

@dreamwasp dreamwasp commented Nov 20, 2025

Overview

Adds props to InfoTip for customizing the button's aria-label and aria-labelledby attribute. 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

  • Related to designs: N/A
  • Related to JIRA ticket: GMT-216
  • I have run this code to verify it works
  • This PR includes unit tests for the code change
  • This PR includes testing instructions for the code change
  • The alpha package of this PR is passing end-to-end tests in all relevant Codecademy repositories

Testing Instructions

Auto-focus + keyboard nav (verify tab order makes sense!):

Floating without links:

  1. Go to Default story with placement: "floating"
  2. Tab to to InfoTip button + press enter - focus should automatically move to the popover content
  3. Press Tab - should wrap back to button (no getting stuck in empty popover)
  4. Also works with VO on click.

Floating with links:

  1. Go to WithLinksOrButtons story
  2. Open with keyboard - focus auto-moves to popover content
  3. Tab through the links - should move naturally
  4. After last link, Tab wraps back to InfoTip button
  5. Shift+Tab from button - should exit backward to previous page element (no trap)

Inline without links:

  1. Go to Default story (default inline placement)
  2. Open with keyboard - focus auto-moves to tip content
  3. Tab - moves to next element in document (normal flow)

Inline with links:

  1. Make a quick test with inline placement + links
  2. Open it - focus auto-moves to content
  3. Tab through - should follow normal document flow with the links

GridForm + ConnectedForm

  1. Head to the infotip section of GridForm or ConnectedForm + check it out

Screen reader check:

  1. Use VO/NVDA to verify custom aria-role, label, and labelledby get announced
  2. Make sure the auto-focus to content is smooth and announced properly

Finish and do a celebratory dance 🎉

PR Links and Envs

Repository PR Link
Monolith Monolith PR
Mono Mono PR

@nx-cloud
Copy link

nx-cloud bot commented Nov 20, 2025

View your CI Pipeline Execution ↗ for commit ef78c2c


☁️ Nx Cloud last updated this comment at 2025-12-17 14:57:19 UTC

@dreamwasp dreamwasp changed the title fix(InfoTip): Remove ariaa-live and implement focus mgmt fix(InfoTip): Remove aria-live and implement focus mgmt Nov 20, 2025
Base automatically changed from cass-ajr-GMT-1479 to main December 4, 2025 18:13
@dreamwasp dreamwasp marked this pull request as ready for review December 11, 2025 18:43
@dreamwasp dreamwasp requested a review from a team as a code owner December 11, 2025 18:43
Copy link
Contributor

@aresnik11 aresnik11 left a 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) });
Copy link
Contributor

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

Comment on lines +338 to +348
fields: [
{
label: 'Email address',
name: 'email',
size: 9,
type: 'email',
infotip: {
info: 'We will never share your email with third parties.',
},
},
],
Copy link
Contributor

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
Screenshot 2025-12-15 at 1 05 24 PM

Comment on lines +99 to +117
## 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} />
Copy link
Contributor

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

I am some helpful yet concise text that needs more explanation
</Text>
<InfoTip
{...args}
Copy link
Contributor

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.' }}
Copy link
Contributor

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={{
Copy link
Contributor

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

@codecademydev
Copy link
Collaborator

📬 Published Alpha Packages:

@codecademy/gamut@67.6.1-alpha.1bf8a5.0
@codecademy/gamut-kit@0.6.574-alpha.1bf8a5.0
@codecademy/styleguide@78.5.4-alpha.1bf8a5.0

@github-actions
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants