- 
                Notifications
    
You must be signed in to change notification settings  - Fork 71
 
[LG-2957] feat: GuideCue - Update Button Focus #3277
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
          🦋 Changeset detectedLatest commit: 8ae34c5 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
 Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR  | 
    
| 
           Size Change: +85 B (+0.01%) Total Size: 1.62 MB 
 ℹ️ View Unchanged
  | 
    
| 
           Coverage after merging ar/LG-2957-close-button into main will be 
 Coverage Report
  | 
    |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
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.
Pull Request Overview
This PR updates the GuideCue component to set initial focus on the primary button instead of relying on default focus behavior, improving user experience when the tooltip opens.
- Replaced 
useIdAllocatorhook withuseRefto reference the primary button for focus targeting - Refactored style functions to use helper methods instead of inline style composition
 - Fixed spelling errors in comments ("multip-step" → "multi-step", "automically" → "automatically", "cloese" → "close")
 
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description | 
|---|---|
| packages/guide-cue/src/GuideCueTooltip/GuideCueTooltip.tsx | Updated focus trap to target primary button using ref instead of ID-based approach; refactored style composition to use helper functions | 
| packages/guide-cue/src/GuideCueTooltip/GuideCueTooltip.styles.ts | Created getCloseButtonStyle and getTooltipStyles helper functions; made internal styles private | 
| packages/guide-cue/src/GuideCue/GuideCue.tsx | Fixed spelling errors in comments | 
| packages/guide-cue/src/GuideCue/GuideCue.spec.tsx | Added tests to verify primary button is focusable for both standalone and multi-step tooltips | 
| .changeset/real-lamps-teach.md | Added changeset for patch release | 
✍️ Proposed changes
Summary
Updates the
GuideCueTooltipto focus on the primary action button instead of the close button when the tooltip opens, improving keyboard navigation and accessibility.Changes
GuideCueTooltipto usefocus-trap-react'sinitialFocusoption to target the primary buttondocument.getElementByIdfor better React practicesMotivation
Previously, when the GuideCueTooltip opened, focus would automatically go to the first focusable element (the close button). This created a suboptimal user experience as users typically want to proceed with the primary action. By focusing the primary button first, we provide better keyboard navigation and align with common UX patterns where the primary action receives initial focus.
Testing
Technical Details
useRefhook to maintain a reference to the primary buttonfocus-trap-react'sinitialFocusoption as a function that returns the button elementuseIdAllocatorusage since the button no longer needs an ID attribute🎟 Jira ticket: Change order of close button
✅ Checklist
For new components
For bug fixes, new features & breaking changes
pnpm changesetand documented my changes🧪 How to test changes