Skip to content

Commit

Permalink
Use preventDefault in _onExpandable handler. Fixes #2484
Browse files Browse the repository at this point in the history
On some touch devices and in certain contexts, a touch event can trigger a second mouse event, causing expandable cards to close as soon as they open. Follows advice from http://www.html5rocks.com/en/mobile/touchandmouse/ to "use preventDefault() inside touch event handlers, so the default mouse-emulation handling doesn’t occur." Even though this can prevent "other default browser behavior (like scrolling)", this shouldn't be a danger in the specific context of this handler.
  • Loading branch information
neverfox committed Dec 12, 2015
1 parent 744b0e7 commit 87b6f0b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/card/card.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ const Card = React.createClass({
style: React.PropTypes.object,
},

_onExpandable() {
_onExpandable(e) {
e.preventDefault();
let newExpandedState = !(this.state.expanded === true);
this.setState({expanded: newExpandedState});
if (this.props.onExpandChange)
Expand Down

0 comments on commit 87b6f0b

Please sign in to comment.