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

Make Simulate.mouseEnter/Leave use direct dispatch #1366

Merged
merged 1 commit into from
Apr 13, 2015

Conversation

sophiebits
Copy link
Collaborator

Fixes #1297.

onMouseEnter and onMouseLeave shouldn't actually use direct dispatch, but doing so is more useful than doing nothing (and I don't think it precludes adding proper enter/leave dispatching later, either).

Test Plan: grunt test

@jordwalke
Copy link
Contributor

Did you see how enter/leave actually has its own dispatch path?
Standard bubbling to target t goes from root to t back to root.

A leave/enter from tstart to tend, dispatches leaves from tstart to the firstCommonAncestor but stops just one short of that common ancestor. enters are dispatched similarly, from the firstCommonAncestor to tend, but starting just one after the first common ancestor on the path to `tend . I think I completely pulled this behavior out of thin air. But it made sense to me and we're at liberty to reimagine mouse events since this is not a standard DOM event :D

@sophiebits
Copy link
Collaborator Author

Yeah, I saw. Enter/leave are now in the spec and I think they work the same way you did?

I didn't have great ideas for a simulation API for that though -- see #1297. I figured direct dispatch is simple and is 99% of the time what you need in a test.

@facebook-github-bot
Copy link

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

@zpao
Copy link
Member

zpao commented Sep 10, 2014

Yay or nay?

@jordwalke
Copy link
Contributor

@spicyj Do you recall our conversation about this and what my thoughts were? I seem to recall saying that the test cases should operate exactly like the actual code that runs in applications.

@ryanzec
Copy link

ryanzec commented Dec 21, 2014

Any update on this? This is a pretty big issue for me since I do commonly use mouseenter/mouseleave and right now I can write any unit tests for those pieces of code.

@@ -314,17 +314,24 @@ function makeSimulator(eventType) {
node = domComponentOrNode;
}

var dispatchConfig = ReactEventEmitter.eventNameDispatchConfigs[eventType];
Copy link

Choose a reason for hiding this comment

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

It looks like the latest code (0.12.1) uses ReactBrowserEventEmitter instead of ReactEventEmitter

@ryanzec
Copy link

ryanzec commented Jan 13, 2015

Any reason why this is not being merged?

@ryanzec
Copy link

ryanzec commented Feb 16, 2015

Another month has gone by, any update on this (this would help greatly with my unit tests)?

Fixes facebook#1297.

onMouseEnter and onMouseLeave shouldn't *actually* use direct dispatch, but doing so is more useful than doing nothing (and I don't think it precludes adding proper enter/leave dispatching later, either).

Test Plan:
grunt test
@sophiebits
Copy link
Collaborator Author

@ryanzec Thanks for the nudge – we had some concern over whether this is the exact final API that we want, but this is an improvement so I agree we should probably merge it.

@zpao r?

@ryanzec
Copy link

ryanzec commented Apr 13, 2015

@spicyj Ok, its been about 2 more months so I figure I would give another nudge. Personally I think it would be better to have something that works than something that does not work. I would rather be able to test now and then have to update my tests if the way to test this event changes then not being able to test this event at all.

sophiebits added a commit that referenced this pull request Apr 13, 2015
Make Simulate.mouseEnter/Leave use direct dispatch
@sophiebits sophiebits merged commit d8117d0 into facebook:master Apr 13, 2015
@sophiebits
Copy link
Collaborator Author

@ryanzec Thanks for the nudge. :)

@vsiao
Copy link
Contributor

vsiao commented Apr 21, 2015

Will this be a 0.14 fix?

@sophiebits
Copy link
Collaborator Author

Yes.

@vsiao
Copy link
Contributor

vsiao commented Apr 21, 2015

Thanks! :]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Simulate.mouseEnter and Simulate.mouseLeave not working
6 participants