Skip to content

Commit 818eb6a

Browse files
author
Dmitry Yadrikhinsky
committed
Stop propagation
1 parent 874787a commit 818eb6a

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

src/screens/projects/components/TaskNode/TaskNode.tsx

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react';
1+
import React, { SyntheticEvent } from 'react';
22
import {
33
CaretRightFilled,
44
DeleteOutlined,
@@ -20,17 +20,30 @@ interface TaskNodeProps {
2020
export default function TaskNode({ model }: TaskNodeProps) {
2121
const duration = useTaskDuration(model);
2222

23+
function preventDefault(fn: () => void) {
24+
return (e: SyntheticEvent) => {
25+
e.stopPropagation();
26+
fn();
27+
};
28+
}
29+
2330
return (
2431
<div className="task-node">
2532
<span className="task-title">{model.title}</span>
2633
<span>{duration}</span>
2734
<span className="task-node__actions">
2835
{!model.active ? (
29-
<CaretRightFilled onClick={() => tasksStore.startTimer(model)} />
36+
<CaretRightFilled
37+
onClick={preventDefault(() => tasksStore.startTimer(model))}
38+
/>
3039
) : (
31-
<PauseOutlined onClick={() => tasksStore.endTimer(model)} />
40+
<PauseOutlined
41+
onClick={preventDefault(() => tasksStore.endTimer(model))}
42+
/>
3243
)}
33-
<DeleteOutlined onClick={() => tasksStore.delete(model)} />
44+
<DeleteOutlined
45+
onClick={preventDefault(() => tasksStore.delete(model))}
46+
/>
3447
</span>
3548
</div>
3649
);

0 commit comments

Comments
 (0)