88 */
99
1010import * as React from 'react' ;
11- import { useCallback , useEffect , useMemo , useRef , useState } from 'react' ;
11+ import { useEffect , useMemo , useRef } from 'react' ;
1212import AutoSizer from 'react-virtualized-auto-sizer' ;
1313import { FixedSizeList } from 'react-window' ;
1414import SnapshotCommitListItem from './SnapshotCommitListItem' ;
@@ -20,7 +20,6 @@ export type ItemData = {|
2020 commitDurations : Array < number > ,
2121 commitTimes : Array < number > ,
2222 filteredCommitIndices : Array < number > ,
23- isMouseDown : boolean ,
2423 maxDuration : number ,
2524 selectedCommitIndex : number | null ,
2625 selectedFilteredCommitIndex : number | null ,
@@ -97,28 +96,6 @@ function List({
9796 }
9897 } , [ listRef , selectedFilteredCommitIndex ] ) ;
9998
100- // When the mouse is down, dragging over a commit should auto-select it.
101- // This provides a nice way for users to swipe across a range of commits to compare them.
102- const [ isMouseDown , setIsMouseDown ] = useState ( false ) ;
103- const handleMouseDown = useCallback ( ( ) => {
104- setIsMouseDown ( true ) ;
105- } , [ ] ) ;
106- const handleMouseUp = useCallback ( ( ) => {
107- setIsMouseDown ( false ) ;
108- } , [ ] ) ;
109- useEffect ( ( ) => {
110- if ( divRef . current === null ) {
111- return ( ) => { } ;
112- }
113-
114- // It's important to listen to the ownerDocument to support the browser extension.
115- // Here we use portals to render individual tabs (e.g. Profiler),
116- // and the root document might belong to a different window.
117- const ownerDocument = divRef . current . ownerDocument ;
118- ownerDocument . addEventListener ( 'mouseup' , handleMouseUp ) ;
119- return ( ) => ownerDocument . removeEventListener ( 'mouseup' , handleMouseUp ) ;
120- } , [ divRef , handleMouseUp ] ) ;
121-
12299 const itemSize = useMemo (
123100 ( ) => Math . max ( minBarWidth , width / filteredCommitIndices . length ) ,
124101 [ filteredCommitIndices , width ] ,
@@ -134,7 +111,6 @@ function List({
134111 commitDurations,
135112 commitTimes,
136113 filteredCommitIndices,
137- isMouseDown,
138114 maxDuration,
139115 selectedCommitIndex,
140116 selectedFilteredCommitIndex,
@@ -144,7 +120,6 @@ function List({
144120 commitDurations ,
145121 commitTimes ,
146122 filteredCommitIndices ,
147- isMouseDown ,
148123 maxDuration ,
149124 selectedCommitIndex ,
150125 selectedFilteredCommitIndex ,
@@ -153,11 +128,7 @@ function List({
153128 ) ;
154129
155130 return (
156- < div
157- onMouseDown = { handleMouseDown }
158- onMouseUp = { handleMouseUp }
159- ref = { divRef }
160- style = { { height, width} } >
131+ < div ref = { divRef } style = { { height, width} } >
161132 < FixedSizeList
162133 className = { styles . List }
163134 layout = "horizontal"
0 commit comments