Skip to content

[Brush] onChange is executed after onBrushEnd #1885

@xavi-ortega

Description

@xavi-ortega

When dragging the brush, the onChange callback is triggered several times during the process, which is correct, but when stop dragging an additional onChange event is triggered right after onBrushEnd.

Is this expected? Is there a workaround I can use to know when drag is finished and not receiving any additional input after finishing?

My use case is updating the main app state during onChange, and when drag ends, I want to show a tooltip with the updated state. The issue is that while dragging (onChange) I have a state with a boolean to avoid showing the tooltip until it really ends, which is inconvenient because I set it to false when onBrushEnd is triggered, but it's back to true again when the last onChange runs.

Demo (fork of Brush doc): https://codesandbox.io/p/sandbox/youthful-browser-vq8x4p
image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions