Skip to content

Commit

Permalink
fix(slider): set null check for value in slider (#16157)
Browse files Browse the repository at this point in the history
* fix(slider): set null check for 0 value in slider

* fix(slider): updated null check for 0 value in slider

---------

Co-authored-by: TJ Egan <tw15egan@gmail.com>
  • Loading branch information
aninaantony and tw15egan committed Apr 25, 2024
1 parent 8bb54fa commit 342e7f3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
13 changes: 11 additions & 2 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -1476,11 +1476,11 @@
"name": "jesnajoseijk",
"avatar_url": "https://avatars.githubusercontent.com/u/38346258?v=4",
"profile": "https://github.com/jesnajoseijk",
"contributions": [
"contributions": [
"code"
]
},
{
{
"login": "Jawahars",
"name": "Jawahar S",
"avatar_url": "https://avatars.githubusercontent.com/u/4353146?v=4",
Expand All @@ -1506,6 +1506,15 @@
"contributions": [
"code"
]
},
{
"login": "aninaantony",
"name": "Anina Antony",
"avatar_url": "https://avatars.githubusercontent.com/u/164350784?v=4",
"profile": "https://github.com/aninaantony",
"contributions": [
"code"
]
}
],
"commitConvention": "none"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -283,12 +283,12 @@ check out our [Contributing Guide](/.github/CONTRIBUTING.md) and our
<td align="center"><a href="https://cuppajoey.com/"><img src="https://avatars.githubusercontent.com/u/14837881?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Joseph Schultz</b></sub></a><br /><a href="https://github.com/carbon-design-system/carbon/commits?author=cuppajoey" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/anjaly0606"><img src="https://avatars.githubusercontent.com/u/99959496?v=4?s=100" width="100px;" alt=""/><br /><sub><b>anjaly0606</b></sub></a><br /><a href="https://github.com/carbon-design-system/carbon/commits?author=anjaly0606" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/jesnajoseijk"><img src="https://avatars.githubusercontent.com/u/38346258?v=4?s=100" width="100px;" alt=""/><br /><sub><b>jesnajoseijk</b></sub></a><br /><a href="https://github.com/carbon-design-system/carbon/commits?author=jesnajoseijk" title="Code">💻</a></td>

</tr>
<tr>
<td align="center"><a href="https://github.com/Jawahars"><img src="https://avatars.githubusercontent.com/u/4353146?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Jawahar S</b></sub></a><br /><a href="https://github.com/carbon-design-system/carbon/commits?author=Jawahars" title="Code">💻</a></td>
<td align="center"><a href="https://hollyos.com/"><img src="https://avatars.githubusercontent.com/u/4097509?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Holly Springsteen</b></sub></a><br /><a href="https://github.com/carbon-design-system/carbon/commits?author=hollyos" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/2nikhiltom"><img src="https://avatars.githubusercontent.com/2nikhiltom?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Nikhil Tomar</b></sub></a><br /><a href="https://github.com/carbon-design-system/carbon/commits?author=2nikhiltom" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/aninaantony"><img src="https://avatars.githubusercontent.com/u/164350784?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Anina Antony</b></sub></a><br /><a href="https://github.com/carbon-design-system/carbon/commits?author=aninaantony" title="Code">💻</a></td>
</tr>
</table>

Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/components/Slider/Slider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1037,7 +1037,7 @@ class Slider extends PureComponent<SliderProps> {
? (boundingRect?.right ?? 0) - clientX
: clientX - (boundingRect?.left ?? 0);
return leftOffset / width;
} else if (value && range) {
} else if (value !== null && value !== undefined && range) {
// Prevent NaN calculation if the range is 0.
return range === 0 ? 0 : (value - this.props.min) / range;
}
Expand Down

0 comments on commit 342e7f3

Please sign in to comment.