diff --git a/packages/strapi-plugin-upload/admin/src/components/InputMedia/index.js b/packages/strapi-plugin-upload/admin/src/components/InputMedia/index.js index ba5d1cc433..214f88c16e 100644 --- a/packages/strapi-plugin-upload/admin/src/components/InputMedia/index.js +++ b/packages/strapi-plugin-upload/admin/src/components/InputMedia/index.js @@ -1,4 +1,4 @@ -import React, { useState } from 'react'; +import React, { useEffect, useState } from 'react'; import PropTypes from 'prop-types'; import { CopyToClipboard } from 'react-copy-to-clipboard'; import { get } from 'lodash'; @@ -32,6 +32,10 @@ const InputMedia = ({ label, onChange, name, attribute, value, type }) => { const displaySlidePagination = attribute.multiple && value.length > 1 ? ` (${fileToDisplay + 1}/${value.length})` : ''; + useEffect(() => { + setFileToDisplay(0); + }, [modal.isOpen]); + const handleClickToggleModal = () => { setModal(prev => ({ isDisplayed: true, step: 'list', isOpen: !prev.isOpen, fileToEdit: null })); };