Skip to content

Commit

Permalink
[Bug] make sure the RangeBrush updates on slider range changes
Browse files Browse the repository at this point in the history
Before this commit, if you have, e.g., a Slider with

    range={[0,10]},
    value={[4,5]},

, then it and its RangeBrush will look like

    ----||----- <- RangeBrush/histogram
    ====||===== <- Slider

. A bug will then appear if you change the Slider's range, say
to

    range={[0,5]},
    value={[4,5]},

: then you will see a situation like

    ----||----- <- RangeBrush (**incorrect**)
    --------|-| <- Slider (correct)

where the RangeBrush has failed to update and so looks out
of sync with its Slider. This commit fixes the problem.

Signed-off-by: Jarrad Whitaker <jwhitaker📧@📧swift-nav.com>
  • Loading branch information
Jarrad Whitaker committed Nov 30, 2022
1 parent c53d81f commit 4848bf5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/components/src/common/range-brush.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,8 @@ function RangeBrushFactory(): React.ComponentType<RangeBrushProps> {
} = this.props;
const [prevVal0, prevVal1] = prevProps.value;

if (prevProps.width !== width) {
// width change should not trigger this._brushed
if (prevProps.width !== width || prevProps.range[0] !== this.props.range[0] || prevProps.range[1] !== this.props.range[1]) {
// dimension change should not trigger this._brushed
this.moving = true;
if (this.brush) this.root?.call(this.brush);
this._move(val0, val1);
Expand Down

0 comments on commit 4848bf5

Please sign in to comment.