Skip to content

Commit

Permalink
fix(rac): Range Slider is not filled
Browse files Browse the repository at this point in the history
Change-Id: I78f199bf5bbc5b3e960a7c17dc3d42c94634a906
GitOrigin-RevId: a8e3b0e72ec0a1b8c5900408ef3bb2bbfe607fd0
  • Loading branch information
sarahsga authored and actions-user committed Dec 16, 2024
1 parent 8ef42dd commit fcaccf1
Showing 1 changed file with 2 additions and 32 deletions.
34 changes: 2 additions & 32 deletions plasmicpkgs/react-aria/src/registerSliderTrack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,32 +26,6 @@ export interface BaseSliderTrackProps
children?: React.ReactElement<HTMLElement>;
}

/**
* Finds the index of the minimum and maximum values in the slider
* @param values
* @returns
*/
function findMinMaxIndices(values: number[]): {
minIndex: number;
maxIndex: number;
} {
let minIndex = 0;
let maxIndex = 0;

if (Array.isArray(values)) {
for (let i = 1; i < values.length; i++) {
if (values[i] < values[minIndex]) {
minIndex = i;
}
if (values[i] > values[maxIndex]) {
maxIndex = i;
}
}
}

return { minIndex, maxIndex };
}

function isMultiValueGuard(value?: number | number[]): value is number[] {
return Array.isArray(value) && value.length > 1;
}
Expand All @@ -66,14 +40,10 @@ export function BaseSliderTrack(props: BaseSliderTrackProps) {
const isMultiValue = thumbsLength > 1;

const { minIndex, maxIndex } = useMemo(() => {
if (
!context ||
!Array.isArray(context.value) ||
context.value.length <= 1
) {
if (thumbsLength <= 1) {
return { minIndex: 0, maxIndex: 0 };
}
return findMinMaxIndices(context.value);
return { minIndex: 0, maxIndex: thumbsLength - 1 };
}, [thumbsLength]);

/**
Expand Down

0 comments on commit fcaccf1

Please sign in to comment.