fix(button-group): keep segmented control hover borders visually consistent#14067
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!
|
This stack of pull requests is managed by Graphite. Learn more about stacking. |
153dd0b to
3f40d32
Compare
There was a problem hiding this comment.
Pull request overview
Fixes a visual border artifact in st.segmented_control caused by overlapping semi-transparent borders on hover by introducing a border “ownership” model (raised active/interactive segments + hiding shared borders on neighbors). Adds E2E visual regression coverage for hover states (including active-adjacent hover) and updates snapshots impacted by the styling change.
Changes:
- Adjust segmented control button styling to raise active/hovered segments and avoid double-width border seams by hiding shared borders on adjacent segments.
- Add a new E2E snapshot test + app cases covering hover border behavior for both multi- and single-selection (including hover next to a selected segment).
- Update/add Playwright snapshot images affected by the new border rendering.
Reviewed changes
Copilot reviewed 3 out of 25 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| frontend/lib/src/components/shared/BaseButton/styled-components.ts | Implements the segmented control border layering/ownership logic using z-index + adjacency selectors. |
| e2e_playwright/st_segmented_control_test.py | Adds hover-border snapshot regression test (multi + single selected-adjacent) and a small helper. |
| e2e_playwright/st_segmented_control.py | Adds new “Hover border regression” section/widgets used by the new E2E test. |
| e2e_playwright/snapshots/linux/st_segmented_control_test/*.png | Updates existing snapshots and adds new hover-border snapshots reflecting the new styling. |
SummaryThis PR fixes a visual border rendering issue in segmented control components (issue #12802). When hovering over buttons in a segmented control, overlapping borders caused double-width seam artifacts. The fix introduces a z-index-based layering system with CSS border-color transparency rules so that "raised" buttons (active or hovered/focused) own shared borders with their neutral neighbors, preventing visual artifacts. Changes:
Code QualityBoth reviewers agreed the CSS implementation is well-structured and maintainable:
No blocking code-quality issues were identified by either reviewer. Test CoverageBoth reviewers agreed the E2E test coverage is strong:
No frontend unit tests were added, which both reviewers considered acceptable since the changes are purely CSS styling rules in Emotion styled components — visual CSS behavior is best verified through E2E visual regression snapshots. Residual gap (both reviewers noted): The CSS logic also handles Backwards CompatibilityBoth reviewers agreed: No concerns. This is a CSS-only visual fix with no API changes, no protobuf changes, and no backend changes. Only affects segmented control button visual rendering. The updated existing snapshots confirm the fix applies consistently. Security & RiskBoth reviewers agreed: No security concerns. Regression risk is low — the fix is scoped to segmented control buttons only, border transparency rules are carefully gated by specificity, and the z-index value used matches the pre-existing focus-visible z-index. AccessibilityBoth reviewers agreed: The changes maintain good accessibility:
RecommendationsNo blocking issues. Non-blocking suggestions from the reviewers:
VerdictAPPROVED: Both reviewers approved. The fix is well-crafted with a clear border ownership model, comprehensive visual regression tests across themes and browsers, and no backwards compatibility, security, or accessibility concerns. The non-blocking suggestions above can be addressed in follow-up PRs if desired. This is a consolidated AI review by 📋 Review by `gpt-5.3-codex-high`SummaryThis PR fixes segmented-control hover border artifacts by introducing explicit shared-border ownership and stacking behavior in button styles, and it adds targeted E2E visual regression coverage for the affected hover cases. The implementation aligns with the linked issue and keeps the change scope focused on styling plus regression tests. Code QualityThe frontend change is well-structured and maintainable: selector constants and inline comments clearly document the border-ownership model, including active precedence and neutral-neighbor hover/focus handling ( Test CoverageCoverage is strong for the reported bug:
Residual gap: the frontend logic also treats Backwards CompatibilityNo API or behavior-breaking changes were introduced for Python or widget contracts. This is a visual/styling fix plus test updates, so backward compatibility impact is low. Security & RiskNo security concerns were identified. AccessibilityAccessibility impact is positive/neutral:
Recommendations
VerdictAPPROVED: The fix is well-scoped, addresses the root visual defect, and is backed by solid E2E regression coverage with no blocking issues found. This is an automated AI review by 📋 Review by `opus-4.6-thinking`SummaryThis PR fixes a visual border rendering issue in segmented control components (issue #12802). When hovering over buttons in a segmented control, overlapping borders caused double-width seam artifacts. The fix introduces a z-index-based layering system with CSS border-color transparency rules so that "raised" buttons (active or hovered/focused) own shared borders with their neutral neighbors, preventing visual artifacts. Changes:
Code QualityThe CSS implementation is well-structured and follows a clear border ownership model:
Test CoverageE2E Tests (visual regression):
Frontend unit tests:
Backwards CompatibilityNo concerns. This is a CSS-only visual fix:
Security & RiskNo security concerns. The changes are purely visual CSS adjustments with no changes to data flow, authentication, or server-side logic. Regression risk is low:
AccessibilityThe changes maintain good accessibility practices:
RecommendationsNo blocking issues. Minor non-blocking observations:
VerdictAPPROVED: Well-crafted CSS bug fix with a clear border ownership model, comprehensive visual regression tests across themes and browsers, and no backwards compatibility or security concerns. This is an automated AI review by |
e743ad6 to
bf3e99c
Compare
There was a problem hiding this comment.
unrelated frustration: i hate when this happens 😢
There was a problem hiding this comment.
can't tell if this is a regression or not... looks like the options aren't vertically aligned anymore... (disclaimer: haven't looked at code yet)
There was a problem hiding this comment.
i don't see any code that would cause this, so i don't want to block on this. big 🤔 though
There was a problem hiding this comment.
but like with this one https://github.com/streamlit/streamlit/pull/14067/changes#r2843019361 it usually moves everything by a couple pixels... bothers me that the borders moved but not the text... maybe just subpixel math?
There was a problem hiding this comment.
Yeah I think this is a subpixel thing. I just compared the actual st_segmented_control.py running on this branch and in the nightly preview and they render exactly the same.
There was a problem hiding this comment.
whew, okay good to know
bf3e99c to
f34a1b7
Compare
f34a1b7 to
6fd50bb
Compare

Describe your changes
Fixed border rendering issue in segmented control components where hovering over buttons would create visual artifacts due to overlapping borders. Implemented a z-index based layering system where active and interactive (hover/focus) buttons are treated as "raised" and take ownership of shared borders with neutral neighbors. This prevents double-width border seams while maintaining proper visual hierarchy.
Added comprehensive E2E tests with visual regression snapshots to verify hover states work correctly for both single and multi-selection modes, including edge cases where hovered buttons are adjacent to selected buttons.
Screenshot or video (only for visual changes)
See snapshot updates!
GitHub Issue Link (if applicable)
Fixes #12802
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.