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

Styled components seems not pass onTouchTap prop in basic tags #527

Closed
ShinyLeee opened this issue Feb 23, 2017 · 6 comments
Closed

Styled components seems not pass onTouchTap prop in basic tags #527

ShinyLeee opened this issue Feb 23, 2017 · 6 comments

Comments

@ShinyLeee
Copy link

Version

1.4.3

Reproduction

http://www.webpackbin.com/4JNcGFDKG

Steps to reproduce

Click 4 anchor tags.

Expected Behavior

All anchor tag show alert message box after touchTap or click.

Actual Behavior

The first anchor tag not show alert.

Description

In this reproduction, seems only basic tags can not receive onTouchTap prop.
I am new to styled-components, so if there is something I lost, please tell me.
Thanks!

@jacobp100
Copy link
Contributor

jacobp100 commented Feb 23, 2017

Looking into it, this is a non-standard event that is monkey patched into tags via react-tap-event-plugin. This is an interesting case, because by looking at the code, it seems like there is an (undocumented) API to add these events.

We filter out non-standard attributes for html elements. I think it would be wrong to add this to that list, and doing that wouldn't extend to other events injected in this way.

This is ultimately caused by the same underlying issue that is effecting #403.

If you need a (hacky) workaround, you can do the following,

const A = (props) => <a {...props} />
const StyledLink = styled(A)`
  color: red;
`

<StyledLink onTouchTap={...}>This should work</StyledLink>

@ShinyLeee
Copy link
Author

Thanks for your reply, I think the workaround is more suitable in this case after find out the reason.

@jacobp100
Copy link
Contributor

Moving discussion to #439

@plankguy
Copy link
Contributor

plankguy commented Jun 2, 2018

I noticed that new React 16.4.0 pointer events aren't in the "non-standard attribute" regex mentioned above. Are there plans to add these in a future release?

The above work-around gets the job done, but i'd like to see built-in support.

@quantizor
Copy link
Contributor

quantizor commented Jun 2, 2018 via email

@plankguy
Copy link
Contributor

plankguy commented Jun 3, 2018

@probablyup Done: #1790

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

No branches or pull requests

4 participants