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

How do I preventDefault inside onKeyUp? #135

Closed
unclechu opened this issue Feb 22, 2018 · 6 comments
Closed

How do I preventDefault inside onKeyUp? #135

unclechu opened this issue Feb 22, 2018 · 6 comments

Comments

@unclechu
Copy link

I don't have Event in this handler to do so.

@ethul
Copy link
Contributor

ethul commented Feb 24, 2018

This is perhaps not a great solution, but would it work to coerce KeyboardEvent to Event? Maybe having a function to do this in the library would be handy, or maybe the events defined in the library can be updated in a way to accommodate this.

@unclechu
Copy link
Author

@ethul Coercing KeyboardEvent to Event is unsafe, because, we can just create an record that satisfies type of KeyboardEvent (that is simple unwrapped record), and by this coercing we can get runtime fails.

@ethul
Copy link
Contributor

ethul commented Feb 24, 2018

Agreed this would be unsafe. Does it temporarily solve your issue? Maybe reworking the way the events are represented would be worth looking further into. I am open to ideas on this.

@unclechu
Copy link
Author

I think type of KeyboardEvent must change, at least, with minimal breaking changes, an event key could be added to the KeyboardEvent type that would have a reference to Event (but in this case, we have to construct new object).

@unclechu
Copy link
Author

Does it temporarily solve your issue?

I haven't tried but it probably will solve it.

@unclechu
Copy link
Author

I think the best way would be to make some newtypes for events and to add some type class like ReactEvent that would have preventDefault and stopPropagation to implement. And KeyboardEvent shouldn't be just a record with simple data, at least it must have some field with FFI type like Event.

@ethul ethul mentioned this issue Mar 4, 2018
@ethul ethul mentioned this issue Apr 10, 2018
ethul added a commit that referenced this issue Apr 14, 2018
Resolves #85
Resolves #135
Resolves #136
ethul added a commit that referenced this issue Apr 14, 2018
Resolves #85
Resolves #135
Resolves #136
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants