From 9bb981925751f849552dc77023ada2b517717976 Mon Sep 17 00:00:00 2001 From: Roman Pearah Date: Sat, 12 Dec 2015 17:03:50 -0500 Subject: [PATCH] Use preventDefault in _onExpandable handler. Fixes #2484 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. Rename e to event in _onExpandable --- src/card/card.jsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/card/card.jsx b/src/card/card.jsx index 1fcd022dbeb3ed..a2a81ecb032541 100644 --- a/src/card/card.jsx +++ b/src/card/card.jsx @@ -22,7 +22,8 @@ const Card = React.createClass({ style: React.PropTypes.object, }, - _onExpandable() { + _onExpandable(event) { + event.preventDefault(); let newExpandedState = !(this.state.expanded === true); this.setState({expanded: newExpandedState}); if (this.props.onExpandChange)