diff --git a/src/components/EditPreview/EditPreview.tsx b/src/components/EditPreview/EditPreview.tsx index 0fcc8ce4..3bd14dad 100644 --- a/src/components/EditPreview/EditPreview.tsx +++ b/src/components/EditPreview/EditPreview.tsx @@ -1,28 +1,24 @@ -import { Button, ButtonType } from '@components/Button'; import { PROFILE_BFIDS } from '@common/constants/bibframe.constants'; import state from '@state'; import classNames from 'classnames'; -import { useRecoilState, useRecoilValue } from 'recoil'; -import { FormattedMessage } from 'react-intl'; +import { useRecoilState, useRecoilValue, useResetRecoilState } from 'recoil'; import { useParams, useSearchParams } from 'react-router-dom'; -import { QueryParams, RESOURCE_CREATE_URLS, ROUTES } from '@common/constants/routes.constants'; +import { QueryParams, RESOURCE_CREATE_URLS } from '@common/constants/routes.constants'; import { ResourceType } from '@common/constants/record.constants'; import { InstancesList } from '@components/InstancesList'; import { useRoutePathPattern } from '@common/hooks/useRoutePathPattern'; -import { useNavigateToEditPage } from '@common/hooks/useNavigateToEditPage'; import { getRecordDependencies } from '@common/helpers/record.helper'; -import { memo } from 'react'; +import { memo, useEffect } from 'react'; import { TitledPreview } from '@components/Preview/TitledPreview'; import './EditPreview.scss'; export const EditPreview = memo(() => { const currentlyPreviewedEntityBfid = useRecoilValue(state.ui.currentlyPreviewedEntityBfid); - const isEdited = useRecoilValue(state.status.recordIsEdited); const record = useRecoilValue(state.inputs.record); const [previewContent, setPreviewContent] = useRecoilState(state.inputs.previewContent); + const resetPreviewContent = useResetRecoilState(state.inputs.previewContent); const isCreatePageOpen = useRoutePathPattern(RESOURCE_CREATE_URLS); const { resourceId } = useParams(); - const { navigateToEditPage } = useNavigateToEditPage(); const [queryParams] = useSearchParams(); const isPositionedSecond = currentlyPreviewedEntityBfid.has(PROFILE_BFIDS.INSTANCE) && currentlyPreviewedEntityBfid.values.length <= 1; @@ -32,26 +28,14 @@ export const EditPreview = memo(() => { const showPreview = (dependencies?.entries?.length === 1 && !isCreateWorkPageOpened) || previewContent.length; const selectedForPreview = previewContent?.[0]; + useEffect(() => resetPreviewContent, [resourceId]); + return (