Skip to content

Commit a4eda9d

Browse files
committed
Хак для быстрого оценивания в firefox
1 parent 5f5052a commit a4eda9d

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

hwproj.front/src/components/Solutions/TaskSolutionComponent.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,12 +232,25 @@ const TaskSolutionComponent: FC<ISolutionProps> = (props) => {
232232
</Grid>}
233233
{!showThumbs && <Grid item>
234234
<Rating
235+
key={solution?.id}
235236
name="customized"
236237
size="large"
237238
defaultValue={2}
238239
max={maxRating}
239240
value={points}
240241
readOnly={!isEditable}
242+
onMouseDown={event => {
243+
const isFirefox = navigator.userAgent.toLowerCase().includes('firefox')
244+
if (event.ctrlKey && isFirefox) {
245+
const ratingElement = event.currentTarget
246+
const {left, width} = ratingElement.getBoundingClientRect()
247+
const relativeX = (event.clientX - left) / width
248+
const star = Math.ceil(relativeX * maxRating) || 0
249+
const rating = star === points ? 0 : star
250+
251+
clickForRate(rating || 0, true)
252+
}
253+
}}
241254
onChange={(_, newValue) => {
242255
clickForRate(newValue || 0, true)
243256
}}

0 commit comments

Comments
 (0)