Skip to content
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

fix: marks calculation when boolean or number is passed #303

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Pareder
Copy link

@Pareder Pareder commented Aug 23, 2023

Hi, I have found that marks property does not work correctly when min is not zero. You can open demo page and adjust the min property of "Slider with marks" example. In that case all marks are out of tracks. Of course I can calculate numbers by myself and pass an array of numbers but I think it is a good adjustment.

image

Also added tests for marks prop and covered marks logic by checking key property.

} else if (typeof marks === 'number') {
marks = Array.from({ length: range })
.map((_, key) => key)
.map((_, key) => key + this.props.min)

Choose a reason for hiding this comment

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

good catch

@msf-caesar
Copy link

Try with adjusting the step property to match the min value of the Slider. This will ensure that the marks are aligned with the track. Additionally, consider using the included property to determine if the marks should be displayed inside or outside the track.

@Pareder
Copy link
Author

Pareder commented Sep 1, 2023

@msf-caesar Why do you think that displaying marks outside is an expected behavior? For me it seems that marks should be inside the track and it should be the default behavior. If user wants to display them outside he would pass an array of numbers:

<ReactSlider
  min={10}
  max={20}
  marks={[-10, 0, 10, 20]}
/>

I don't want to overcomplicate this logic with additional prop included.

@zachmerrill
Copy link

Would love to see this get merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants