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

Completely ignore clicks on disabled items #382

Merged
merged 4 commits into from
Aug 25, 2015

Conversation

bhstahl
Copy link

@bhstahl bhstahl commented Aug 14, 2015

Add functionality to completely ignore clicks on disabled items, unless the target of the click is a link (super edge case, I know).

@bhstahl
Copy link
Author

bhstahl commented Aug 14, 2015

Intends to close #381

@bruderstein
Copy link
Collaborator

Great catch! Thanks for adding the extra tests too. The test that disabled option links are clickable needs to actually check something though - I'm not sure how to do that, but there should be an expect after the TestUtils.Simulate.click(link). Maybe you could check window.location.href afterwards? Or spy on window.open with a link with target?

Probably be worth adding a test for the links with target too, which is where the coverage drop comes from I guess.

There might be issues with the slightly dumb DOM emulation here - there's a better one that's been suggested by @chantastic for generator-react-component, I'd like to integrate that, then maybe testing this sort of thing will be easier.

@bhstahl
Copy link
Author

bhstahl commented Aug 17, 2015

Hey @bruderstein, thanks! Ah, sorry I meant to leave a note in there that it's 80% of the way through but somehow forgot before having to dash on Friday.

Looks like window isn't currently available in the tests, so I looked into something similar to unexpected-dom for document but didn't really get anywhere. I also tried mocking the window object to no avail. Will look into react-media-object though!

@bhstahl
Copy link
Author

bhstahl commented Aug 20, 2015

@bruderstein Totally missed that window is on the global namespace so I was able to test clicking the link does navigate the location :). The only thing missing is testing that links with target="_blank" actually open a new window (couldn't find a something like phantomjs's onPageCreated in jsdom) but I am testing that clicking those links don't navigated the current window. Let me know if you want me to add anything else!

@JedWatson
Copy link
Owner

@bhstahl that looks great, it looks like there are conflicts with recent changes though - would you mind checking that and rebasing so I can merge this? Thanks!

@bhstahl
Copy link
Author

bhstahl commented Aug 24, 2015

@JedWatson good to go! Thanks

@JedWatson
Copy link
Owner

Thanks @bhstahl! Would you mind removing the build / dist files? We just need the src changes in PRs.

Nearly there :)

@bhstahl
Copy link
Author

bhstahl commented Aug 25, 2015

Whoops, sorry about that as well @JedWatson . Fixed and also squashed some of the redundant test file commits.

@JedWatson
Copy link
Owner

Much better @bhstahl - thanks :D

JedWatson added a commit that referenced this pull request Aug 25, 2015
Completely ignore clicks on disabled items
@JedWatson JedWatson merged commit 2ffedd4 into JedWatson:master Aug 25, 2015
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.

3 participants