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

Listen to input changes event only, while retaining access to the raw values in the callback #587

Closed
DekelYossef opened this issue Oct 25, 2021 · 5 comments · Fixed by #591
Assignees

Comments

@DekelYossef
Copy link

Hi,

I'm trying to listen to user changes explicitly, and not to every value change due other event types or prop changes, and to get the values.value or values.floatValue in a callback for easy parsing and handling.

What would be the right way to do so?

Since I can't access the event object in onValueChange, and can't find out what's the source of the onValueChange which gets triggered for multiple reasons, I can't use it. Other option I see is using the input's onChange handler, but I get the formatted value from it which requires de-formatting to actually parse the value.

I re-read the documentation, and searched for similar issues, and all I managed to find was #429, and more specifically, this:

Hello, i have approximately the same problem. When the props value change the onValueChange is fired!! It creates infinite loop when an input update another input vice versa.

Originally posted by @alexandre033 in #429 (comment)

My case is a bit different since I don't update the input value's state and thus there is no infinite loop, but I do get the onValueChange triggered when I don't want it to, and can't filter out the specific events I want to listen to.

I would have expected that either I get the values object in the onChange callback or get the source / reason / trigger for the onValueChange. Is there something I'm missing?

Thanks! 🙏🏼

@s-yadav
Copy link
Owner

s-yadav commented Nov 3, 2021

Humm, the reason we don't want to do it onChange is that, onChange doesn't get called on all cases. Like value can change due to multiple source, prop change, input change, blur. so onChange might not receive all the updates. Also changing the semantic of onChange shouldn't be done.

But I think we can add the source information in the second param of onValueChange, like mentioned in
#429 (comment)

We will add this, as this is most asked requirement.

@s-yadav
Copy link
Owner

s-yadav commented Nov 3, 2021

@nikhil-varma, can you look into this.?

@nikhil-varma
Copy link
Collaborator

@s-yadav sure!

@nikhil-varma nikhil-varma self-assigned this Nov 3, 2021
@nikhil-varma nikhil-varma linked a pull request Nov 8, 2021 that will close this issue
6 tasks
@nikhil-varma
Copy link
Collaborator

@DekelYossef We have extended the onValueChange callback to allow sending source details as discussed! Please try it out and let us know if you have any further questions. Closing this issue as of now

@DekelYossef
Copy link
Author

Will do! thank you guys!

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

Successfully merging a pull request may close this issue.

3 participants