Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onClick event support for the handleComponent #776

Open
Guardpc opened this issue Oct 7, 2022 · 2 comments
Open

onClick event support for the handleComponent #776

Guardpc opened this issue Oct 7, 2022 · 2 comments

Comments

@Guardpc
Copy link

Guardpc commented Oct 7, 2022

I, like many other people, feel the need to use the click event for additional functionality.
Similar problem: #753

@josh-unwin
Copy link

josh-unwin commented Nov 29, 2022

I've had a look into this and it's related to onMouseDown taking priority over onClick, blocking it from calling.

A workaround is to use use the onResizeStop prop like this:

onResizeStop={(e, direction, ref, d) => {
    if (d.width === 0 && d.height === 0) {
        // This means user just clicked and didnt drag, treat it as a click.
        yourOnClickLogicHere()
    } else {
        setWidth(width + d.width);
    }
}}

d.width and d.height is how far the mouse was dragged. If these are zero you can treat it like a click.

In my example I'm only resizing the width, but you can handle d.height in the same way.

@virendave96
Copy link

onResizeStop doesn't work for me in my use case what I did is implemented onMouseDown in handleComponent and used event.stopPropagation as per my need.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants