Skip to content

Commit

Permalink
Revert "fix: ouvre tous les menus articles par défaut"
Browse files Browse the repository at this point in the history
Car le comportement ou les menus de niveau 1 restent ouvert n'est pas implémenté
codegouvfr/react-dsfr#282

This reverts commit 1a7827e.
  • Loading branch information
martinratinaud committed Jul 17, 2024
1 parent 1a7827e commit 3fd957d
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions src/components/Ressources/Ressource.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<>
<Header
Expand All @@ -56,8 +63,8 @@ const Ressource = ({ ressourceKey }: { ressourceKey: string }) => {
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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down

0 comments on commit 3fd957d

Please sign in to comment.