From 3fd957d97335210878ec0b40cc98101f8fe2f7d3 Mon Sep 17 00:00:00 2001 From: Martin Ratinaud Date: Wed, 17 Jul 2024 10:22:44 +0400 Subject: [PATCH] =?UTF-8?q?Revert=20"fix:=20ouvre=20tous=20les=20menus=20a?= =?UTF-8?q?rticles=20par=20d=C3=A9faut"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Car le comportement ou les menus de niveau 1 restent ouvert n'est pas implémenté https://github.com/codegouvfr/react-dsfr/issues/282 This reverts commit 1a7827ede211de6070659c307746341d9f2ca5d1. --- src/components/Ressources/Ressource.tsx | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/components/Ressources/Ressource.tsx b/src/components/Ressources/Ressource.tsx index 69230d20f..dd6deb452 100644 --- a/src/components/Ressources/Ressource.tsx +++ b/src/components/Ressources/Ressource.tsx @@ -39,6 +39,13 @@ const Ressource = ({ ressourceKey }: { ressourceKey: string }) => { }; }, [router, ressourceKey]); + const selected = { + issues: Object.keys(issues).includes(ressourceKey), + understandings: Object.keys(understandings).includes(ressourceKey), + growths: Object.keys(growths).includes(ressourceKey), + coldNetworks: Object.keys(coldNetworks).includes(ressourceKey), + }; + return ( <>
{ items={[ { text: 'Les enjeux de la transition énergétique avec les réseaux de chaleur', - isActive: Object.keys(issues).includes(ressourceKey), - expandedByDefault: true, + isActive: selected.issues, + expandedByDefault: selected.issues, items: Object.entries(issues).map(([key, issue]) => ({ text: issue.title, isActive: ressourceKey === key, @@ -69,8 +76,8 @@ const Ressource = ({ ressourceKey }: { ressourceKey: string }) => { }, { text: 'Les réseaux de chaleur en pratique : tout comprendre pour se raccorder', - isActive: Object.keys(understandings).includes(ressourceKey), - expandedByDefault: true, + isActive: selected.understandings, + expandedByDefault: selected.understandings, items: Object.entries(understandings).map(([key, issue]) => ({ text: issue.title, isActive: ressourceKey === key, @@ -82,8 +89,8 @@ const Ressource = ({ ressourceKey }: { ressourceKey: string }) => { }, { text: 'Une filière en pleine croissance', - isActive: Object.keys(growths).includes(ressourceKey), - expandedByDefault: true, + isActive: selected.growths, + expandedByDefault: selected.growths, items: Object.entries(growths).map(([key, issue]) => ({ text: issue.title, isActive: ressourceKey === key, @@ -95,8 +102,8 @@ const Ressource = ({ ressourceKey }: { ressourceKey: string }) => { }, { text: "Les réseaux de froid, un enjeu pour l'avenir", - isActive: Object.keys(coldNetworks).includes(ressourceKey), - expandedByDefault: true, + isActive: selected.coldNetworks, + expandedByDefault: selected.coldNetworks, items: Object.entries(coldNetworks).map(([key, issue]) => ({ text: issue.title, isActive: ressourceKey === key,