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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Slider] Remove not needed mark in range Sliders #31960

Closed
2 tasks done
SooriyanDSRC opened this issue Mar 23, 2022 · 6 comments 路 Fixed by #33526
Closed
2 tasks done

[Slider] Remove not needed mark in range Sliders #31960

SooriyanDSRC opened this issue Mar 23, 2022 · 6 comments 路 Fixed by #33526
Labels
bug 馃悰 Something doesn't work component: slider This is the name of the generic UI component, not the React module!

Comments

@SooriyanDSRC
Copy link

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Current behavior 馃槸

Whenever both the start and the end points have been dragged to the end of the slider an extra mark has been added at the end of the slider which is visible when both the drag points aren't at the end.

Expected behavior 馃

The extra mark in the slider must be removed and retain the required marks that has been provided in the props.

Steps to reproduce 馃暪

Steps:

  1. Add marks to the range slider for both range start and end as follows.
    image
  2. Drag both the range points to the end of the slider.
    image
  3. Now drag both the range points from the end to another position.
    image
  4. Now we will be able to get three marks where the third one isn't a required one and must have been removed.

Context 馃敠

We have been using the range slider for a requirement in our project, where the user needs to choose certain range and the user needs to be provided with the labels of their selections. Since the marks might overwrite one another we needed to keep the marks to the minimal amount, In this case its getting added up by one.

Your environment 馃寧

`npx @mui/5.5.2`
  Chrome latest version
  Output from `npx @mui/5.5.2` goes here.
@SooriyanDSRC SooriyanDSRC added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Mar 23, 2022
@danilo-leal danilo-leal changed the title Range Slider Marks: Remove mark which is not needed [Slider] Remove not needed mark in range Sliders Mar 23, 2022
@danilo-leal danilo-leal added the component: slider This is the name of the generic UI component, not the React module! label Mar 23, 2022
@michaldudak
Copy link
Member

Hi @SooriyanDSRC, could you please provide a codesandbox showing the problem? It may be that a certain combination of props causes the problem.

@michaldudak michaldudak added status: waiting for author Issue with insufficient information and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels May 23, 2022
@kkalvako
Copy link

I face the same issue. @michaldudak here is a codesandbox link in case it helps.

https://codesandbox.io/s/material-demo-forked-tlu40e?file=/demo.js

@michaldudak
Copy link
Member

Right, definitely a bug. Would you like to contribute to the project and look for a fix?

@michaldudak michaldudak added bug 馃悰 Something doesn't work and removed status: waiting for author Issue with insufficient information labels Jul 11, 2022
@kskd1804
Copy link
Contributor

@michaldudak Sure, I would be happy to work on the fix. The issue seems to be arising due to both marks having the same key as shown in the below image.

image

How does this look?

diff --git a/packages/mui-base/src/SliderUnstyled/SliderUnstyled.js b/packages/mui-base/src/SliderUnstyled/SliderUnstyled.js
index 4536cbe2c1..5559e274d4 100644
--- a/packages/mui-base/src/SliderUnstyled/SliderUnstyled.js
+++ b/packages/mui-base/src/SliderUnstyled/SliderUnstyled.js
@@ -210,7 +210,7 @@ const SliderUnstyled = React.forwardRef(function SliderUnstyled(props, ref) {
           }
 
           return (
-            <React.Fragment key={mark.value}>
+            <React.Fragment key={index}>
               <Mark
                 data-index={index}
                 {...markProps}

@michaldudak
Copy link
Member

Looks good to me. Please create a PR with this change.

@kskd1804
Copy link
Contributor

@michaldudak Created the PR #33526

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 馃悰 Something doesn't work component: slider This is the name of the generic UI component, not the React module!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants