Bug 1451683 - Avoid reacting to mousedown twice in a row when starting to drag the splitter; r=miker
MozReview-Commit-ID: ClTdZ03tB0U
--- a/devtools/client/shared/components/splitter/Draggable.js
+++ b/devtools/client/shared/components/splitter/Draggable.js
@@ -23,31 +23,45 @@ class Draggable extends Component {
constructor(props) {
super(props);
this.startDragging = this.startDragging.bind(this);
this.onMove = this.onMove.bind(this);
this.onUp = this.onUp.bind(this);
}
startDragging(ev) {
+ if (this.isDragging) {
+ return;
+ }
+ this.isDragging = true;
+
ev.preventDefault();
const doc = ReactDOM.findDOMNode(this).ownerDocument;
doc.addEventListener("mousemove", this.onMove);
doc.addEventListener("mouseup", this.onUp);
this.props.onStart && this.props.onStart();
}
onMove(ev) {
+ if (!this.isDragging) {
+ return;
+ }
+
ev.preventDefault();
// Use viewport coordinates so, moving mouse over iframes
// doesn't mangle (relative) coordinates.
this.props.onMove(ev.clientX, ev.clientY);
}
onUp(ev) {
+ if (!this.isDragging) {
+ return;
+ }
+ this.isDragging = false;
+
ev.preventDefault();
const doc = ReactDOM.findDOMNode(this).ownerDocument;
doc.removeEventListener("mousemove", this.onMove);
doc.removeEventListener("mouseup", this.onUp);
this.props.onStop && this.props.onStop();
}
render() {