diff --git a/frontend/cypress/e2e/back_office/regulation_form/creation.spec.ts b/frontend/cypress/e2e/back_office/regulation_form/creation.spec.ts index cadcc2fb9a..f3a7829349 100644 --- a/frontend/cypress/e2e/back_office/regulation_form/creation.spec.ts +++ b/frontend/cypress/e2e/back_office/regulation_form/creation.spec.ts @@ -256,11 +256,11 @@ context('BackOffice > Regulation Form > Creation', () => { cy.get('[name="fishing_period_annual_recurrence"]').eq(0).click() cy.fill('Début', [2024, 10, 10]) - cy.fill('Début', [2024, 10, 31]) + cy.fill('Fin', [2024, 10, 31]) cy.contains('Plages de dates').parent().parent().find('a').eq(0).click() cy.fill('Début', [2024, 12, 10], { index: 1 }) - cy.fill('Début', [2024, 12, 31], { index: 1 }) + cy.fill('Fin', [2024, 12, 31], { index: 1 }) cy.get('[data-cy="weekday-lundi"]').click() cy.get('[data-cy="weekday-mercredi"]').click() diff --git a/frontend/src/features/Regulation/components/RegulatoryZoneMetadata/index.tsx b/frontend/src/features/Regulation/components/RegulatoryZoneMetadata/index.tsx index b0b990be75..f93cbbf4b4 100644 --- a/frontend/src/features/Regulation/components/RegulatoryZoneMetadata/index.tsx +++ b/frontend/src/features/Regulation/components/RegulatoryZoneMetadata/index.tsx @@ -4,7 +4,7 @@ import { useMainAppDispatch } from '@hooks/useMainAppDispatch' import { useMainAppSelector } from '@hooks/useMainAppSelector' import { useTracking } from '@hooks/useTracking' import { Icon, THEME } from '@mtes-mct/monitor-ui' -import { useCallback } from 'react' +import { useEffect } from 'react' import styled from 'styled-components' import { FishingPeriodDisplayed } from './fishingPeriod' @@ -24,11 +24,15 @@ export function RegulatoryZoneMetadata() { const regulatoryZoneMetadata = useMainAppSelector(state => state.regulation.regulatoryZoneMetadata) const regulatoryZoneMetadataPanelIsOpen = useMainAppSelector(state => state.regulation.regulatoryZoneMetadata) - const onCloseIconClicked = useCallback(() => { + const onCloseIconClicked = () => { dispatch(closeRegulatoryZoneMetadata()) - }, [dispatch]) + } - trackPage(`/regulation_metadata/${regulatoryZoneMetadata?.topic}/${regulatoryZoneMetadata?.zone}`) + useEffect(() => { + if (regulatoryZoneMetadataPanelIsOpen) { + trackPage(`/regulation_metadata/${regulatoryZoneMetadata?.topic}/${regulatoryZoneMetadata?.zone}`) + } + }, [trackPage, regulatoryZoneMetadataPanelIsOpen, regulatoryZoneMetadata]) return (