@@ -233,19 +233,24 @@ class SnapshotSelector extends PureComponent<SnapshotSelectorProps, SnapshotSele
233
233
// $FlowFixMe createRef()
234
234
listRef = React . createRef ( ) ;
235
235
236
+ state : SnapshotSelectorState = {
237
+ isMouseDown : false ,
238
+ } ;
239
+
236
240
componentDidUpdate ( prevProps ) {
237
241
// Make sure any newly selected snapshot is visible within the list.
238
242
if ( this . props . snapshotIndex !== prevProps . snapshotIndex ) {
239
243
this . listRef . current . scrollToItem ( this . props . snapshotIndex ) ;
240
244
}
241
245
}
242
246
243
- state : SnapshotSelectorState = {
244
- isMouseDown : false ,
245
- } ;
247
+ componentWillUnmount ( ) {
248
+ window . removeEventListener ( 'mouseup' , this . handleMouseUp ) ;
249
+ }
246
250
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
+ } ) ;
249
254
handleMouseUp = event => this . setState ( { isMouseDown : false } ) ;
250
255
251
256
render ( ) {
@@ -275,7 +280,6 @@ class SnapshotSelector extends PureComponent<SnapshotSelectorProps, SnapshotSele
275
280
return (
276
281
< div
277
282
onMouseDown = { this . handleMouseDown }
278
- onMouseLeave = { this . handleMouseLeave }
279
283
onMouseUp = { this . handleMouseUp }
280
284
style = { { height, width } }
281
285
>
0 commit comments