Skip to content
This repository was archived by the owner on Jun 26, 2020. It is now read-only.

Commit 0c79424

Browse files
author
Brian Vaughn
committed
When dragging, don't leave the dragging state until you release the mouse. (Even if you mouse outside of the selector.)
1 parent ba9f1d6 commit 0c79424

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

plugins/Profiler/views/SnapshotSelector.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -233,19 +233,24 @@ class SnapshotSelector extends PureComponent<SnapshotSelectorProps, SnapshotSele
233233
// $FlowFixMe createRef()
234234
listRef = React.createRef();
235235

236+
state: SnapshotSelectorState = {
237+
isMouseDown: false,
238+
};
239+
236240
componentDidUpdate(prevProps) {
237241
// Make sure any newly selected snapshot is visible within the list.
238242
if (this.props.snapshotIndex !== prevProps.snapshotIndex) {
239243
this.listRef.current.scrollToItem(this.props.snapshotIndex);
240244
}
241245
}
242246

243-
state: SnapshotSelectorState = {
244-
isMouseDown: false,
245-
};
247+
componentWillUnmount() {
248+
window.removeEventListener('mouseup', this.handleMouseUp);
249+
}
246250

247-
handleMouseDown = event => this.setState({ isMouseDown: true });
248-
handleMouseLeave = event => this.setState({ isMouseDown: false });
251+
handleMouseDown = event => this.setState({ isMouseDown: true }, () => {
252+
window.addEventListener('mouseup', this.handleMouseUp);
253+
});
249254
handleMouseUp = event => this.setState({ isMouseDown: false });
250255

251256
render() {
@@ -275,7 +280,6 @@ class SnapshotSelector extends PureComponent<SnapshotSelectorProps, SnapshotSele
275280
return (
276281
<div
277282
onMouseDown={this.handleMouseDown}
278-
onMouseLeave={this.handleMouseLeave}
279283
onMouseUp={this.handleMouseUp}
280284
style={{ height, width }}
281285
>

0 commit comments

Comments
 (0)