[feat] Add scroll arrows for overflowing tabs in st.tabs#13987
[feat] Add scroll arrows for overflowing tabs in st.tabs#13987lukasmasuch merged 11 commits intodevelopfrom
st.tabs#13987Conversation
When tabs overflow their container horizontally, clickable left/right arrow buttons appear to allow users to scroll through the tabs. The arrows conditionally show based on scroll position.
✅ 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.
Pull request overview
This PR adds horizontal scroll arrows to st.tabs that appear when tabs overflow their container. The arrows are interactive buttons positioned absolutely over the tab list, using a gradient background to fade into the content. The implementation includes proper accessibility features (aria-labels, focus-visible styling) and uses passive scroll listeners for performance.
Changes:
- Adds left/right scroll arrow buttons that conditionally render based on scroll position
- Removes the static gradient fade effect previously used for overflow indication
- Implements scroll state tracking with event listeners and callback hooks
- Adds E2E tests for scroll arrow behavior and visual snapshots
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| frontend/lib/src/components/elements/Tabs/styled-components.ts | Removed static gradient fade effect and added new StyledScrollArrow button component with gradient backgrounds and accessibility styling |
| frontend/lib/src/components/elements/Tabs/Tabs.tsx | Implemented scroll state management with hooks, added scroll event listener, and rendered conditional scroll arrow buttons with click handlers |
| frontend/lib/src/components/elements/Tabs/Tabs.test.tsx | Added basic unit test verifying scroll arrows don't appear when tabs don't overflow |
| e2e_playwright/st_tabs_test.py | Added functional test for scroll arrow interaction and snapshot test for visual appearance in light/dark themes |
|
@cursor review |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
- Add ResizeObserver to update scroll arrows on container resize - Use theme.shadows.focusRing for consistent focus styling - Replace hardcoded timeout with Playwright expect() assertions
Add wait_for_timeout(500) after clicking the scroll arrow to allow the smooth scroll animation to complete before taking the snapshot. The scroll uses behavior: "smooth" which animates over ~200-400ms, and without waiting, the snapshot captures inconsistent scroll positions leading to 2-5% pixel differences across browsers/themes.
SummaryThis PR adds clickable left/right scroll arrows to Code QualityGood patterns observed:
Minor observations:
Test CoverageFrontend unit test (
E2E tests (
Coverage gaps (minor):
Backwards CompatibilityNo breaking changes. The modifications are purely frontend and internal:
Security & RiskNo security concerns. This is a self-contained frontend UI enhancement with no new network calls, no data handling changes, and no new dependencies (the Risk assessment: Low. The change only affects visual presentation and scroll interaction of the tab bar. The Accessibility
Recommendations
VerdictAPPROVED: Well-implemented feature with proper React patterns, good accessibility support, comprehensive E2E snapshots, and no backwards compatibility concerns. The minor suggestions above are optional improvements that can be addressed in follow-up work. This is an automated AI review by |
Consolidated Code Review: PR #13987 — [feat] Add scroll arrows for overflowing tabs in
|
| className="stTabs" | ||
| data-testid="stTabs" | ||
| isOverflowing={isOverflowing} | ||
| tabHeight={TAB_HEIGHT} |
There was a problem hiding this comment.
This was needed for the previous gradient indicator
There was a problem hiding this comment.
question: is the back arrow intended to be a different color?
There was a problem hiding this comment.
I guess the right arrow is hovered, that's why it has a lighter color compared to the left one. I will add a reset for the hovering.
… for regeneration The reset_hovering call ensures the hover state is cleared before taking the snapshot, which prevents flaky test results when arrow buttons retain hover effects from the preceding click interaction.
Resolve merge conflicts by combining: - Tabs overflow scroll arrows (this branch) - Dynamic tabs widget state tracking (develop)
CI-generated snapshots for the tabs overflow arrow tests after reset_hovering fix.
There was a problem hiding this comment.
suggestion: Perhaps we can now remove this padding?
| @@ -86,6 +92,34 @@ function Tabs(props: Readonly<TabProps>): ReactElement { | |||
| const theme = useEmotionTheme() | |||
|
|
|||
| const [isOverflowing, setIsOverflowing] = useState(false) | |||
There was a problem hiding this comment.
suggestion: I think we can now simplify isOverflowing = canScrollLeft || canScrollRight
mayagbarnes
left a comment
There was a problem hiding this comment.
Couple suggestions along with the graphite comment (re: SCROLL_TOLERANCE) , but overall LGTM!
- Use SCROLL_TOLERANCE for left scroll check consistency (fixes potential flickering near left edge from floating-point rounding) - Derive isOverflowing from canScrollLeft || canScrollRight instead of tracking as separate state - Remove extra padding on last tab (no longer needed with interactive scroll arrows)
## Describe your changes - Add clickable left/right scroll arrows that appear when tabs overflow their container horizontally - Arrows conditionally show based on scroll position: left arrow appears when scrolled right, right arrow appears when content overflows to the right - Include accessibility support with aria-labels and focus-visible styling for keyboard navigation - Use passive scroll event listeners for better performance ## Github Issues - Closes #5552 ## Testing Plan - [x] Unit Tests (JS and/or Python) - [x] E2E Tests
Describe your changes
Github Issues
Testing Plan