Skip to content

Commit

Permalink
Don't show slider fill before value equal to initial value (#6853)
Browse files Browse the repository at this point in the history
  • Loading branch information
evansjohnson committed Jun 19, 2024
1 parent 45461a2 commit 6273c37
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/core/src/components/slider/slider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export class Slider extends AbstractPureComponent<SliderProps> {
<MultiSlider.Handle
value={value!}
intentAfter={value! < initialValue! ? intent : undefined}
intentBefore={value! >= initialValue! ? intent : undefined}
intentBefore={value! > initialValue! ? intent : undefined}
onChange={onChange}
onRelease={onRelease}
htmlProps={handleHtmlProps}
Expand Down
15 changes: 15 additions & 0 deletions packages/core/test/slider/sliderTests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,21 @@ describe("<Slider>", () => {
assert.equal(tracks.getDOMNode().getBoundingClientRect().width, STEP_SIZE * 3);
});

it("renders primary track segment between initialValue and value when value is less than initial value", () => {
const tracks = renderSlider(<Slider showTrackFill={true} initialValue={5} value={2} />).find(
`.${Classes.SLIDER_PROGRESS}.${Classes.INTENT_PRIMARY}`,
);
assert.lengthOf(tracks, 1);
assert.equal(tracks.getDOMNode().getBoundingClientRect().width, STEP_SIZE * 3);
});

it("renders no primary track segment when value equals initial value", () => {
const tracks = renderSlider(<Slider showTrackFill={true} initialValue={2} value={2} min={0} max={5} />).find(
`.${Classes.SLIDER_PROGRESS}.${Classes.INTENT_PRIMARY}`,
);
assert.lengthOf(tracks, 0);
});

it("renders result of labelRenderer() in each label and differently in handle", () => {
const labelRenderer = (val: number, opts?: { isHandleTooltip: boolean }) =>
val + (opts?.isHandleTooltip ? "!" : "#");
Expand Down

1 comment on commit 6273c37

@svc-palantir-github
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't show slider fill before value equal to initial value (#6853)

Build artifact links for this commit: documentation | landing | table | demo

This is an automated comment from the deploy-preview CircleCI job.

Please sign in to comment.