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

add support for touch event #39

Merged
merged 1 commit into from
Jan 4, 2015
Merged

Conversation

fraserxu
Copy link
Contributor

@fraserxu fraserxu commented Jan 4, 2015

  • For the option, I add an onClick event
  • For the clear button, I add an onClick event
  • For the wrapper, I add an onTouchEnd event
  • For the Value.js, I add an onTouchEnd event

@@ -17,7 +17,7 @@ var Option = React.createClass({
render: function() {
return (
<div className="Select-item">
<span className="Select-item-icon" onMouseDown={this.blockEvent} onClick={this.props.onRemove}>&times;</span>
<span className="Select-item-icon" onMouseDown={this.blockEvent} onClick={this.props.onRemove} onTouchEnd={this.props.onRemove}>&times;</span>
Copy link
Owner

Choose a reason for hiding this comment

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

Shouldn't the onClick handler still fire here on a touch device? or is it blocked by the onMouseDown handler?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, I tested, the onClick does not fire on a touch device.

Add the onTouchEnd will make it work.

I also tried to change the onTouchEnd handler to

onTouchHanlder: function(e) {
  this.blockEvent(e)
  this.props.onRemove()
}

to prevent the input filed from focusing, but seems not work.

@JedWatson
Copy link
Owner

Thanks @fraserxu. I was initially concerned that binding both mouseDown and onClick to the same event handler might cause it to incorrectly fire twice for desktop users, but it may not be an issue... can you confirm this is correct?

@fraserxu
Copy link
Contributor Author

fraserxu commented Jan 4, 2015

Hi @JedWatson I checked the mouseDown and onClick on desktop, it will only fire once even after I added the onTouchEnd listener.

Till now all seems work well for me.

@JedWatson
Copy link
Owner

Cool. I'll merge it now so we can finally support mobile devices.

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.

2 participants