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

Documentation for simulate is minimal and dblclick event is named doubleclick #310

Closed
mordrax opened this issue Apr 11, 2016 · 4 comments
Closed

Comments

@mordrax
Copy link

mordrax commented Apr 11, 2016

I tried to simulate a double click like this:

component.find('[id="purse"]').parent().simulate('dblclick');

Because the documentation for simulate seems to suggest dom events are used.
I'm pretty sure (although could be wrong) that the dom event for double click is dblclick.

Then I looked through the repo and found mentions of doubleclick, and doing this:

component.find('[id="purse"]').parent().simulate('doubleclick');

works.

So it would be good to have a list of simulated events other than click because that's in every tut and example but there's no documentation about the list of events that can be simulated.
Does this have something to do with it?

@ljharb
Copy link
Member

ljharb commented Apr 11, 2016

You're simulating React events, not DOM events, which is why doubleClick is expected - but yes, I think perhaps the native name there needs to change from doubleclick to dblclick.

@mordrax
Copy link
Author

mordrax commented Apr 12, 2016

I see, so it has to do with react's event system which is why the function is called nativeToReactEventMap:

export function mapNativeEventNames(event) {
  const nativeToReactEventMap = {
    compositionend: 'compositionEnd',

Of course, well that makes sense now :)

Two things:

  1. Even on the react events page, there is no doc on what the actual event name is, just the onDoubleClick handler. But looking in the code, they declare it as doubleClick here and then map to the DOM event here
  2. Following on from that, if you're mapping to React events, and they call it 'doubleClick', then it doesn't make sense for it to be changed to dblClick unless you want to change all event names to DOM events?

It seems like documentation is the only thing missing here.

@ljharb
Copy link
Member

ljharb commented Apr 12, 2016

Since it's "native" to "react event" map, the "native" should match native - so I think that the key in https://github.com/airbnb/enzyme/blob/699ec7e39560a68c198ecf80b59d177d003fc869/src/Utils.js#L230 should indeed be changed to "dblclick" to match user expectations.

@mordrax
Copy link
Author

mordrax commented Apr 12, 2016

Yeah ok, gotcha.

ljharb added a commit to ljharb/enzyme that referenced this issue Apr 12, 2016
dustinsanders pushed a commit to dustinsanders/enzyme that referenced this issue Apr 30, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants