Skip to content

Commit d37272d

Browse files
authored
feat: support opening solution from table cell in new window (by ctrl/cmd) (#608)
1 parent 7dc239b commit d37272d

1 file changed

Lines changed: 18 additions & 3 deletions

File tree

hwproj.front/src/components/Tasks/StudentStatsCell.tsx

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,28 @@ const StudentStatsCell: FC<ITaskStudentCellProps & { borderLeftColor?: string }>
3636
<Chip color={"default"} size={"small"} label={ratedSolutionsCount}/>
3737
</Stack>;
3838

39+
const handleCellClick = (e: React.MouseEvent) => {
40+
// Формируем URL
41+
const url = forMentor
42+
? `/task/${props.taskId}/${props.studentId}`
43+
: `/task/${props.taskId}`
44+
// Проверяем, была ли нажата Ctrl/Cmd
45+
const isSpecialClick = e.ctrlKey || e.metaKey;
46+
47+
if (isSpecialClick) {
48+
// Открываем в новой вкладке
49+
window.open(url, '_blank', 'noopener,noreferrer');
50+
} else {
51+
// Переходим в текущей вкладке
52+
navigate(url);
53+
}
54+
};
55+
3956
return (
4057
<Tooltip arrow disableInteractive enterDelay={2000}
4158
title={<span style={{whiteSpace: 'pre-line'}}>{tooltipTitle}</span>}>
4259
<TableCell
43-
onClick={() => forMentor
44-
? navigate(`/task/${props.taskId}/${props.studentId}`)
45-
: navigate(`/task/${props.taskId}`)}
60+
onClick={handleCellClick}
4661
component="td"
4762
padding="none"
4863
variant={"body"}

0 commit comments

Comments
 (0)