From 0d67424f927b9ecd906d7cd1495b94ee8873828d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9e?= Date: Sat, 16 Nov 2024 13:49:18 +0000 Subject: [PATCH] Fix chapter selection (#3117) * Fix chapter selection The event type was wrong, in this case with mui you have to use `.target` and not `.currentTarget`. * lint --- src/components/Dialogs/EditMediaDialog/Chapters.tsx | 5 +++-- src/components/Form/Select.jsx | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/components/Dialogs/EditMediaDialog/Chapters.tsx b/src/components/Dialogs/EditMediaDialog/Chapters.tsx index aa1cfbf51..4b62efb48 100644 --- a/src/components/Dialogs/EditMediaDialog/Chapters.tsx +++ b/src/components/Dialogs/EditMediaDialog/Chapters.tsx @@ -2,6 +2,7 @@ import clsx from 'clsx'; import formatDuration from 'format-duration'; import { useTranslator } from '@u-wave/react-translate'; import MenuItem from '@mui/material/MenuItem'; +import type { SelectChangeEvent } from '@mui/material'; import Select from '../../Form/Select'; type Chapter = { @@ -26,8 +27,8 @@ function Chapters({ onChange, }: ChaptersProps) { const { t } = useTranslator(); - const handleChange = (event: React.FormEvent<{ value: number }>) => { - const newIndex = event.currentTarget.value; + const handleChange = (event: SelectChangeEvent) => { + const newIndex = Number(event.target.value); if (available[newIndex] != null) { onChange(available[newIndex]); } diff --git a/src/components/Form/Select.jsx b/src/components/Form/Select.jsx index 2f76d6177..66a34313b 100644 --- a/src/components/Form/Select.jsx +++ b/src/components/Form/Select.jsx @@ -14,6 +14,7 @@ function Select({ className, classes, tabIndex, + onChange, ...props }) { return ( @@ -24,6 +25,7 @@ function Select({ inputComponent={SelectInput} {...props} inputProps={{ + onChange, children, IconComponent: SvgIcon, iconProps: { path: mdiMenuDown }, @@ -41,6 +43,7 @@ Select.propTypes = { className: PropTypes.string, tabIndex: PropTypes.number, classes: PropTypes.object, + onChange: PropTypes.func, }; export default Select;