Skip to content

Commit

Permalink
fix(Slider Range): position of yellow range with min and max values
Browse files Browse the repository at this point in the history
  • Loading branch information
RobelTekle committed Aug 30, 2023
1 parent cae5ca6 commit 1522de6
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/Slider/src/Range.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export interface RangeOptions extends Omit<SliderOptions, 'type' | 'value' | 'on
export type RangeProps = CreateWuiProps<'div', RangeOptions>

/**
* Ensure mininum of a given value against a value `toCompare` based on a step
* Ensure minimum of a given value against a value `toCompare` based on a step
*/
const ensureMin = ({
min,
Expand Down Expand Up @@ -158,7 +158,9 @@ export const Range = forwardRef<'div', RangeProps>(
const getPercent = useCallback(
(value: number) => {
const percent = Math.round(((value - min) / (max - min)) * 100)
return percent > max ? max : percent < min ? min : percent
if (percent < 0) return 0
if (percent > 100) return 100
return percent
},
[min, max]
)
Expand Down

0 comments on commit 1522de6

Please sign in to comment.