Skip to content

Commit d498186

Browse files
authored
Update SnapshotCommitListItem.js
1 parent f771152 commit d498186

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

packages/react-devtools-shared/src/devtools/views/Profiler/SnapshotCommitListItem.js

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*/
99

1010
import * as React from 'react';
11-
import {memo, useCallback} from 'react';
11+
import {memo} from 'react';
1212
import {areEqual} from 'react-window';
1313
import {getGradientColor, formatDuration, formatTime} from './utils';
1414

@@ -39,11 +39,6 @@ function SnapshotCommitListItem({data: itemData, index, style}: Props) {
3939
const commitDuration = commitDurations[index];
4040
const commitTime = commitTimes[index];
4141

42-
const memoizedSelectCommitIndex = useCallback(
43-
() => selectCommitIndex(index),
44-
[index, selectCommitIndex],
45-
);
46-
4742
// Guard against commits with duration 0
4843
const percentage =
4944
Math.min(1, Math.max(0, commitDuration / maxDuration)) || 0;
@@ -52,14 +47,17 @@ function SnapshotCommitListItem({data: itemData, index, style}: Props) {
5247
// Leave a 1px gap between snapshots
5348
const width = parseFloat(style.width) - 1;
5449

55-
const handleMouseDown = (e: any) => {
56-
memoizedSelectCommitIndex();
57-
const rect = e.target.getBoundingClientRect();
58-
startCommitDrag({
59-
dragStartCommitIndex: index,
60-
rectLeft: rect.left,
61-
width,
62-
});
50+
const handleMouseDown = ({buttons, target}: any) => {
51+
if (buttons === 1) {
52+
selectCommitIndex(index);
53+
54+
// TODO Count for border/margin
55+
startCommitDrag({
56+
commitIndex: index,
57+
left: target.getBoundingClientRect().left,
58+
sizeIncrement: parseFloat(style.width),
59+
});
60+
}
6361
};
6462

6563
return (

0 commit comments

Comments
 (0)