fix: correctly use track for selection

This commit is contained in:
Timothy Z. 2026-04-23 19:47:32 +02:00
parent 3c417a3306
commit 0d1358d6cb
2 changed files with 6 additions and 3 deletions

View file

@ -39,6 +39,9 @@ const SubtitleVariant = ({ track, selected, onSelect }: Props) => {
const variantLabel = hasValidLabel(track.label) ? track.label : languages.label(track.lang);
const downloadFileName = hasValidLabel(track.label) ? track.label : `subtitle-${track.lang || 'unknown'}`;
const canCopyUrl = typeof downloadUrl === 'string' && !downloadUrl.startsWith('blob:');
const hoverTitle = hasValidLabel(track.label)
? track.label
: downloadUrl?.split('/').pop()?.split('?')[0] || variantLabel;
const onSelectClick = useCallback(() => {
onSelect(track);
@ -65,7 +68,7 @@ const SubtitleVariant = ({ track, selected, onSelect }: Props) => {
return (
<Button
ref={buttonRef}
title={variantLabel}
title={hoverTitle}
onClick={onSelectClick}
className={classNames(styles['variant-option'], { 'selected': selected })}
>

View file

@ -106,11 +106,11 @@ const SubtitlesMenu = React.memo(React.forwardRef((props, ref) => {
const subtitlesTrackOnSelect = React.useCallback((track) => {
if (track.embedded) {
if (typeof props.onSubtitlesTrackSelected === 'function') {
props.onSubtitlesTrackSelected(track.id);
props.onSubtitlesTrackSelected(track);
}
} else {
if (typeof props.onExtraSubtitlesTrackSelected === 'function') {
props.onExtraSubtitlesTrackSelected(track.id);
props.onExtraSubtitlesTrackSelected(track);
}
}
}, [props.onSubtitlesTrackSelected, props.onExtraSubtitlesTrackSelected]);