-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
[Slider][material][base] Allow generic value type to narrow onChange value type #38127
Conversation
Co-authored-by: elhadis <[email protected]>
Netlify deploy previewhttps://deploy-preview-38127--material-ui.netlify.app/ Bundle size report |
Co-authored-by: elhadis <[email protected]>
Co-authored-by: elhadis <[email protected]>
Co-authored-by: elhadis <[email protected]>
Hi @DiegoAndai this PR is ready for review. Note that I used a union of different call signatures to define the slider |
Hi @gitstart! thanks for working on this Sadly, I don't think this is solving the issue we want to solve 😕 Look at this codesandbox: https://codesandbox.io/s/slider-onchange-type-pr-37854-llcchv?file=/src/App.tsx In the example, the slider is "single value" (as the value is a We either have to extract the type from the value prop (I don't know if this one is possible) or transform the Slider into a generic component. @michaldudak what's your take on this? |
@DiegoAndai thanks for the feedback. We actually tried exploring the first suggestion (extracting the type from the value prop), but it didn't work out. I think it's worth trying out your second suggestion. |
Description
Narrow Slider onChange value type to be either
number
ornumber[]
depending on the type of thevalue
argument.Updated
onChange
prop in:packages/mui-base/src/useSlider/useSlider.types.ts
packages/mui-material-next/src/Slider/Slider.types.ts
packages/mui-material/src/Slider/Slider.d.ts
Closes #37854
This code was written and reviewed by GitStart Community. Growing great engineers, one PR at a time.