Compare commits

...

1 Commits

Author SHA1 Message Date
vladislavkeblysh
fea78afa85 fix: Fixed delete for additional video url fields (backport) (#2471)
Backport of 2470
2025-12-10 15:13:27 -08:00
3 changed files with 9 additions and 9 deletions

View File

@@ -78,6 +78,7 @@ exports[`VideoSourceWidget snapshots snapshots: renders as expected with default
</div> </div>
<Form.Row <Form.Row
className="mt-3.5 mx-0 flex-nowrap" className="mt-3.5 mx-0 flex-nowrap"
key="somEUrL"
> >
<Form.Group> <Form.Group>
<Form.Control <Form.Control
@@ -86,7 +87,6 @@ exports[`VideoSourceWidget snapshots snapshots: renders as expected with default
<IconButtonWithTooltip <IconButtonWithTooltip
alt="Delete" alt="Delete"
iconAs="Icon" iconAs="Icon"
key="top-delete-somEUrL"
onClick={[Function]} onClick={[Function]}
tooltipContent="Delete" tooltipContent="Delete"
tooltipPlacement="top" tooltipPlacement="top"
@@ -237,6 +237,7 @@ exports[`VideoSourceWidget snapshots snapshots: renders as expected with videoSh
</div> </div>
<Form.Row <Form.Row
className="mt-3.5 mx-0 flex-nowrap" className="mt-3.5 mx-0 flex-nowrap"
key="somEUrL"
> >
<Form.Group> <Form.Group>
<Form.Control <Form.Control
@@ -245,7 +246,6 @@ exports[`VideoSourceWidget snapshots snapshots: renders as expected with videoSh
<IconButtonWithTooltip <IconButtonWithTooltip
alt="Delete" alt="Delete"
iconAs="Icon" iconAs="Icon"
key="top-delete-somEUrL"
onClick={[Function]} onClick={[Function]}
tooltipContent="Delete" tooltipContent="Delete"
tooltipPlacement="top" tooltipPlacement="top"

View File

@@ -39,16 +39,17 @@ export const sourceHooks = ({ dispatch, previousVideoId, setAlert }) => ({
export const fallbackHooks = ({ fallbackVideos, dispatch }) => ({ export const fallbackHooks = ({ fallbackVideos, dispatch }) => ({
addFallbackVideo: () => dispatch(actions.video.updateField({ fallbackVideos: [...fallbackVideos, ''] })), addFallbackVideo: () => dispatch(actions.video.updateField({ fallbackVideos: [...fallbackVideos, ''] })),
/** /**
* Deletes the first occurrence of the given videoUrl from the fallbackVideos list * Deletes the first occurrence of the given videoUrl from the fallbackVideos list
* @param {string} videoUrl - the video URL to delete * @param {string} videoUrl - the video URL to delete
*/ */
deleteFallbackVideo: (videoUrl) => { deleteFallbackVideo: (videoIndex) => {
const index = fallbackVideos.findIndex(video => video === videoUrl);
const updatedFallbackVideos = [ const updatedFallbackVideos = [
...fallbackVideos.slice(0, index), ...fallbackVideos.slice(0, videoIndex),
...fallbackVideos.slice(index + 1), ...fallbackVideos.slice(videoIndex + 1),
]; ];
dispatch(actions.video.updateField({ fallbackVideos: updatedFallbackVideos })); dispatch(actions.video.updateField({ fallbackVideos: updatedFallbackVideos }));
}, },
}); });

View File

@@ -101,7 +101,7 @@ const VideoSourceWidget = ({
<FormattedMessage {...messages.fallbackVideoMessage} /> <FormattedMessage {...messages.fallbackVideoMessage} />
</div> </div>
{fallbackVideos.formValue.length > 0 ? fallbackVideos.formValue.map((videoUrl, index) => ( {fallbackVideos.formValue.length > 0 ? fallbackVideos.formValue.map((videoUrl, index) => (
<Form.Row className="mt-3.5 mx-0 flex-nowrap"> <Form.Row className="mt-3.5 mx-0 flex-nowrap" key={videoUrl}>
<Form.Group> <Form.Group>
<Form.Control <Form.Control
floatingLabel={intl.formatMessage(messages.fallbackVideoLabel)} floatingLabel={intl.formatMessage(messages.fallbackVideoLabel)}
@@ -110,13 +110,12 @@ const VideoSourceWidget = ({
onBlur={fallbackVideos.onBlur(index)} onBlur={fallbackVideos.onBlur(index)}
/> />
<IconButtonWithTooltip <IconButtonWithTooltip
key={`top-delete-${videoUrl}`}
tooltipPlacement="top" tooltipPlacement="top"
tooltipContent={intl.formatMessage(messages.deleteFallbackVideo)} tooltipContent={intl.formatMessage(messages.deleteFallbackVideo)}
src={DeleteOutline} src={DeleteOutline}
iconAs={Icon} iconAs={Icon}
alt={intl.formatMessage(messages.deleteFallbackVideo)} alt={intl.formatMessage(messages.deleteFallbackVideo)}
onClick={() => deleteFallbackVideo(videoUrl)} onClick={() => deleteFallbackVideo(index)}
/> />
</Form.Group> </Form.Group>
</Form.Row> </Form.Row>