Skip to content

Make onPress more life-like #674

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

Closed
wants to merge 1 commit into from

Conversation

hontas
Copy link
Contributor

@hontas hontas commented Mar 1, 2021

Taking inspiration from user-event which tries to mimic the real event order when user interacts with an element.

Summary

fireEvent.press currently only invoke the onPress-handler, and this PR aim to make it more real-life-like by also invoking onPressIn, onPressOut and onFocus if possible (silently failing if there are no registered handlers).

Also adding fireEvent.longPress for convenience.

Test plan

Test added in fireEvent.test.js

Thoughts

One could discuss that this should be another method called tap or something else that map closer to user intent than to event handler name. Looking forward to hear your feedback.

Copy link
Member

@thymikee thymikee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great addition, thank you!

@hontas
Copy link
Contributor Author

hontas commented Mar 1, 2021

Removed the throwing behaviour from invokeEvent here: #691
That PR should be merged before this one :)

@thymikee
Copy link
Member

thymikee commented Mar 2, 2021

Mind rebasing? :)

@hontas hontas force-pushed the user-like-tap-event branch from 6cafc39 to 5247b6a Compare March 3, 2021 13:05
@hontas hontas force-pushed the user-like-tap-event branch from 5247b6a to eeee8f7 Compare March 3, 2021 13:08
@hontas
Copy link
Contributor Author

hontas commented Mar 3, 2021

@thymikee done :)

@rarenatoe
Copy link

Will this ever be merged? I need to be able to work with onFocus and I can't test it atm.

@thymikee
Copy link
Member

thymikee commented Apr 8, 2022

@rarenatoe we'll take care of it, but have no timeline. In the meantime you can invoke fireEvent(element, 'onFocus') manually

@AugustinLF
Copy link
Collaborator

Long term, shouldn't we try to to either create native-user-event package, or at least export something specific for that in this library? I'm not sure that having a different behaviour between the web and native library when doing a simple fireEvent is the best.

@mdjastrzebski
Copy link
Member

Closing in favour of #1119 which would be more organised approach that is also similar to RTL.

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 this pull request may close these issues.

5 participants