Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@lukasmasuch
Copy link
Collaborator

@lukasmasuch lukasmasuch commented Aug 29, 2025

Describe your changes

Show the slider tick labels on hover:

Screen.Recording.2025-08-29.at.11.51.31.mov

Closes #12136


Contribution License Agreement

By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.

@snyk-io
Copy link
Contributor

snyk-io bot commented Aug 29, 2025

🎉 Snyk checks have passed. No issues have been found so far.

security/snyk check is complete. No issues have been found. (View Details)

license/snyk check is complete. No issues have been found. (View Details)

@github-actions
Copy link
Contributor

github-actions bot commented Aug 29, 2025

✅ PR preview is ready!

Name Link
📦 Wheel file https://core-previews.s3-us-west-2.amazonaws.com/pr-12367/streamlit-1.49.1-py3-none-any.whl
🕹️ Preview app pr-12367.streamlit.app (☁️ Deploy here if not accessible)

@lukasmasuch lukasmasuch changed the title [Prototype] Show slider tick labels on hover Show slider tick labels on hover Sep 16, 2025
@lukasmasuch lukasmasuch added security-assessment-completed Security assessment has been completed for PR change:feature PR contains new feature or enhancement implementation impact:users PR changes affect end users labels Sep 16, 2025
@lukasmasuch lukasmasuch requested a review from Copilot September 16, 2025 21:22
Copy link
Contributor

Copilot AI left a 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 implements a feature to show slider tick labels (min/max values) on hover, improving user experience by providing visual feedback when interacting with sliders.

  • Adds hover state management to show/hide tick labels with smooth transitions
  • Implements a new SliderTickBar component to display formatted min/max values
  • Includes comprehensive test coverage for both unit and e2e scenarios

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
frontend/lib/src/components/widgets/Slider/styled-components.ts Adds styled component for tick bar with hover-based opacity transitions
frontend/lib/src/components/widgets/Slider/Slider.tsx Implements hover state management and SliderTickBar component integration
frontend/lib/src/components/widgets/Slider/Slider.test.tsx Adds unit tests for tick bar visibility behavior on hover and keyboard interaction
e2e_playwright/st_slider_test.py Adds e2e test for slider tick bar visibility with snapshot testing
e2e_playwright/st_select_slider_test.py Adds e2e test for select slider tick bar visibility with snapshot testing

@lukasmasuch lukasmasuch marked this pull request as ready for review September 16, 2025 21:23
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is expected that the labels will be cut off in the snapshot since they are positioned outside of the slider boundaries. This also has the small benefit of ensuring that the placement is correct.

data-testid="stSlider"
onMouseEnter={() => setIsHovered(true)}
onMouseLeave={() => setIsHovered(false)}
style={{ position: "relative" }}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: This should be leveraging styled-components.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated 👍

Comment on lines 255 to 256
onMouseEnter={() => setIsHovered(true)}
onMouseLeave={() => setIsHovered(false)}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (non-blocking): Stabilize these via useCallback to prevent unnecessary re-renders.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated 👍

expect(tickBar).toBeVisible()

await user.unhover(sliderContainer)
expect(tickBar).not.toBeVisible()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: Is it possible for these tests to flake due to timing issues?

Looks like opacity has a 70ms transition for opacity on it. If it's possible, then waitFor(() => expect(tickBar).not.toBeVisible()) would be preferred in all of these places that assert visibility state of the Tick Bar

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it might already work since it's an ease-in animation, so it's already visible in the first ms. But adding a waitFor here doesn't seem to hurt.

@lukasmasuch lukasmasuch enabled auto-merge (squash) September 16, 2025 23:24
@lukasmasuch lukasmasuch merged commit 289b258 into develop Sep 16, 2025
38 checks passed
@lukasmasuch lukasmasuch deleted the feature/slider-ticks-on-hover branch September 16, 2025 23:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

change:feature PR contains new feature or enhancement implementation impact:users PR changes affect end users security-assessment-completed Security assessment has been completed for PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

slider and select_slider tick labels

3 participants