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

onChange is being invoked on every click #8

Closed
yoavmmn opened this issue Jun 23, 2019 · 5 comments

Comments

Projects
None yet
2 participants
@yoavmmn
Copy link

commented Jun 23, 2019

The onChange function is being invoked on every click, anywhere on the window.
I'm trying to use this component and update the pattern to redux and the server, but this issue causes performance issues.

@WinterCore

This comment has been minimized.

Copy link
Owner

commented Jun 23, 2019

Hi
I don't understand what you mean by that onChange is being invoked on every click, It's the onRelease that gets called on every click (mouseup) event which in turn calls the onChange after checking that there's at least 1 pattern point selected.
Can you elaborate more please ?
Thanks.

@yoavmmn

This comment has been minimized.

Copy link
Author

commented Jun 23, 2019

What I mean is that the function provided to onChange prop is being called even when I click on other elements, not just the lock pattern.

@WinterCore

This comment has been minimized.

Copy link
Owner

commented Jun 23, 2019

I wasn't able to reproduce this, I might be doing something wrong.
Could you please reproduce it in a codesandbox example or a github repo

@yoavmmn

This comment has been minimized.

Copy link
Author

commented Jun 23, 2019

You can see what I mean here.
After you enter the correct pattern, everything you click on will invoke the onChange function.

@WinterCore

This comment has been minimized.

Copy link
Owner

commented Jun 23, 2019

You're right, This issue occurs only if you use the freeze prop.
Even though #9 Fixes the issue, it raises another issue. Adding the release event listeners on the wrapper will cause issues if the user releases the mouse button outside the wrapper (the mouse would still be connected to the last selected pattern point even when the user is not holding the mouse button)
The issue has been addressed in 1.4.1.
Thanks for reporting this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.