-
Notifications
You must be signed in to change notification settings - Fork 4k
[refactor] Centralize focus ring styling #13340
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
[refactor] Centralize focus ring styling #13340
Conversation
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
✅ PR preview is ready!
|
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 pull request significantly improves the accessibility of tooltip icons and markdown heading anchor links across the Streamlit application. The changes introduce keyboard navigation support for help tooltips and anchor links, add proper ARIA labels, and fix HTML structure issues related to nested labels.
Key Changes
- Tooltip icons are now keyboard-focusable with a button wrapper and proper ARIA labels
- Markdown heading anchor links are accessible via keyboard with visibility improvements using opacity instead of the visibility CSS property
- Fixed nested
<label>element issues by changingStyledWidgetLabelHelpInlinefrom a label to a span element
Reviewed changes
Copilot reviewed 34 out of 34 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
frontend/lib/src/components/shared/TooltipIcon/TooltipIcon.tsx |
Refactored TooltipIcon to render a focusable button with mandatory aria-label, added getHelpTooltipAriaLabel helper function, and enforced type safety via discriminated union |
frontend/lib/src/components/shared/TooltipIcon/styled-components.ts |
Added StyledTooltipTriggerButton with focus-visible styles and updated CSS selector for SVG styling |
frontend/lib/src/components/shared/TooltipIcon/TooltipIcon.test.tsx |
Added tests for keyboard focus, blur behavior, Escape key handling, and aria-label normalization |
frontend/lib/src/components/shared/Tooltip/Tooltip.tsx |
Implemented Escape key handler to dismiss focus-triggered tooltips by blurring the active element |
frontend/lib/src/components/shared/StreamlitMarkdown/StreamlitMarkdown.tsx |
Added aria-label to heading anchor links and aria-hidden to decorative SVG icons |
frontend/lib/src/components/shared/StreamlitMarkdown/styled-components.ts |
Changed anchor link visibility from visibility: hidden to opacity: 0 with pointerEvents: none to keep links in tab order, added focus-within styles |
frontend/lib/src/components/shared/StreamlitMarkdown/Heading.test.tsx |
Updated test assertions for accessible anchor links |
frontend/lib/src/components/widgets/BaseWidget/WidgetLabel.tsx |
Wrapped label text in aria-hidden span while keeping children (help icons) accessible |
frontend/lib/src/components/widgets/BaseWidget/WidgetLabelHelpIconInline.tsx |
Created new wrapper component to consolidate inline help icon usage with proper aria-label handling |
frontend/lib/src/components/widgets/BaseWidget/styled-components.ts |
Changed StyledWidgetLabelHelpInline from label to span to prevent nested label elements |
frontend/lib/src/components/widgets/BaseWidget/index.ts |
Exported new WidgetLabelHelpIconInline component |
frontend/lib/src/components/widgets/BaseWidget/WidgetLabel.test.tsx |
Added tests verifying help icons remain accessible and no nested labels are rendered |
| Widget files (TimeInput, TextInput, TextArea, Slider, NumberInput, Multiselect, FileUploader, DateTimeInput, DateInput, CameraInput, AudioInput) | Updated TooltipIcon usage to include getHelpTooltipAriaLabel(element.label) for proper ARIA labeling |
frontend/lib/src/components/widgets/Checkbox/Checkbox.tsx |
Migrated from StyledWidgetLabelHelpInline + TooltipIcon to WidgetLabelHelpIconInline component |
frontend/lib/src/components/widgets/ButtonGroup/ButtonGroup.tsx |
Migrated to WidgetLabelHelpIconInline component |
frontend/lib/src/components/widgets/ChatInput/fileUpload/ChatFileUploadButton.tsx |
Added aria-label to BaseButton wrapped by TooltipIcon |
frontend/lib/src/components/shared/Radio/Radio.tsx |
Migrated to WidgetLabelHelpIconInline component |
frontend/lib/src/components/shared/Dropdown/Selectbox.tsx |
Added getHelpTooltipAriaLabel(label) to TooltipIcon |
frontend/lib/src/components/shared/BaseColorPicker/BaseColorPicker.tsx |
Migrated to WidgetLabelHelpIconInline component |
frontend/lib/src/components/elements/Metric/Metric.tsx |
Migrated to WidgetLabelHelpIconInline component |
e2e_playwright/st_slider_test.py |
Added test for keyboard-accessible help tooltip |
e2e_playwright/st_markdown_test.py |
Added test for keyboard-focusable and visible anchor icons |
e2e_playwright/st_heading_test.py |
Added test for keyboard-accessible anchor icons and updated CSS property assertions from visibility to opacity |
e2e_playwright/shared/app_utils.py |
Added tab_until_focused utility function for resilient keyboard navigation testing |
frontend/lib/src/components/shared/TooltipIcon/styled-components.ts
Outdated
Show resolved
Hide resolved
frontend/lib/src/components/shared/StreamlitMarkdown/styled-components.ts
Show resolved
Hide resolved
78303c9 to
4685cd8
Compare
📈 Frontend coverage change detectedThe frontend unit test (vitest) coverage has increased by 0.0100%
✅ Coverage change is within normal range. |
dae7b87 to
096a34d
Compare
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
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
frontend/lib/src/components/shared/StreamlitMarkdown/styled-components.ts
Show resolved
Hide resolved
096a34d to
5678480
Compare
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
Copilot reviewed 9 out of 9 changed files in this pull request and generated no new comments.
5678480 to
11d03f4
Compare

Describe your changes
GitHub Issue Link (if applicable)
Testing Plan
Contribution License Agreement
By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.