Skip to content

Commit

Permalink
Fix chapter selection (#3117)
Browse files Browse the repository at this point in the history
* Fix chapter selection

The event type was wrong, in this case with mui you have to use
`.target` and not `.currentTarget`.

* lint
  • Loading branch information
goto-bus-stop authored Nov 16, 2024
1 parent a964d8a commit 0d67424
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/components/Dialogs/EditMediaDialog/Chapters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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<number>) => {
const newIndex = Number(event.target.value);
if (available[newIndex] != null) {
onChange(available[newIndex]);
}
Expand Down
3 changes: 3 additions & 0 deletions src/components/Form/Select.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ function Select({
className,
classes,
tabIndex,
onChange,
...props
}) {
return (
Expand All @@ -24,6 +25,7 @@ function Select({
inputComponent={SelectInput}
{...props}
inputProps={{
onChange,
children,
IconComponent: SvgIcon,
iconProps: { path: mdiMenuDown },
Expand All @@ -41,6 +43,7 @@ Select.propTypes = {
className: PropTypes.string,
tabIndex: PropTypes.number,
classes: PropTypes.object,
onChange: PropTypes.func,
};

export default Select;

0 comments on commit 0d67424

Please sign in to comment.