@eeacms/volto-marine-policy 1.1.4 → 1.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -4,11 +4,14 @@ All notable changes to this project will be documented in this file. Dates are d
4
4
 
5
5
  Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
6
6
 
7
- ### [1.1.4](https://github.com/eea/volto-marine-policy/compare/1.1.3...1.1.4) - 29 April 2024
7
+ ### [1.1.5](https://github.com/eea/volto-marine-policy/compare/1.1.4...1.1.5) - 6 May 2024
8
8
 
9
- #### :rocket: New Features
9
+ #### :bug: Bug Fixes
10
10
 
11
- - feat: add styleMenu styles [nileshgulia1 - [`582bc26`](https://github.com/eea/volto-marine-policy/commit/582bc26a9363181699e178e9adb6ae8449ceaab3)]
11
+ - fix: eslint . [nileshgulia1 - [`6280d19`](https://github.com/eea/volto-marine-policy/commit/6280d191037782ce11c491b681b9e20878da15f2)]
12
+ - fix(navigation): do not expand accordion without children [nileshgulia1 - [`057e1ca`](https://github.com/eea/volto-marine-policy/commit/057e1ca6966b023cb9354ba437c9879c8f1e14d4)]
13
+
14
+ ### [1.1.4](https://github.com/eea/volto-marine-policy/compare/1.1.3...1.1.4) - 29 April 2024
12
15
 
13
16
  ### [1.1.3](https://github.com/eea/volto-marine-policy/compare/1.1.2...1.1.3) - 25 April 2024
14
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-marine-policy",
3
- "version": "1.1.4",
3
+ "version": "1.1.5",
4
4
  "description": "@eeacms/volto-marine-policy: Volto add-on",
5
5
  "main": "src/index.js",
6
6
  "author": "European Environment Agency: IDM2 A-Team",
@@ -1,12 +1,12 @@
1
1
  import React from 'react';
2
2
  import { Accordion as SemanticAccordion, Icon } from 'semantic-ui-react';
3
-
4
3
  import AccordionContent from './AccordionContent';
5
4
  import { useHistory } from 'react-router-dom';
6
5
 
7
6
  const Accordion = (props) => {
8
7
  const { items = {}, curent_location, activeMenu, data = {} } = props;
9
8
  const [currentIndex, setIndex] = React.useState(activeMenu ?? 0);
9
+ const [showChildren, setShowChildren] = React.useState(false);
10
10
  const history = useHistory();
11
11
 
12
12
  const handleClick = (e, item) => {
@@ -19,6 +19,7 @@ const Accordion = (props) => {
19
19
  const newIndex = currentIndex === index ? -1 : index;
20
20
  setIndex(newIndex);
21
21
  };
22
+
22
23
  return (
23
24
  <>
24
25
  <div className="context-navigation-header">{data?.title}</div>
@@ -45,7 +46,7 @@ const Accordion = (props) => {
45
46
  }}
46
47
  >
47
48
  <span className="item-title">{item.title}</span>
48
- {active ? (
49
+ {active && showChildren ? (
49
50
  <Icon
50
51
  className="ri-arrow-up-s-line"
51
52
  onClick={(e) => {
@@ -61,7 +62,7 @@ const Accordion = (props) => {
61
62
  />
62
63
  )}
63
64
  </SemanticAccordion.Title>
64
- <SemanticAccordion.Content active={active}>
65
+ <SemanticAccordion.Content active={active && showChildren}>
65
66
  <AccordionContent
66
67
  curent_location={curent_location}
67
68
  key={index}
@@ -71,6 +72,7 @@ const Accordion = (props) => {
71
72
  url: item.url,
72
73
  }}
73
74
  data={data}
75
+ setShowChildren={setShowChildren}
74
76
  />
75
77
  </SemanticAccordion.Content>
76
78
  </SemanticAccordion>
@@ -10,6 +10,7 @@ const AccordionContent = (props) => {
10
10
  main,
11
11
  curent_location,
12
12
  data: { types = [] },
13
+ setShowChildren,
13
14
  } = props;
14
15
  const location = main.url;
15
16
 
@@ -22,6 +23,14 @@ const AccordionContent = (props) => {
22
23
  // (state) => state.content?.subrequests?.[location]?.data?.items || [],
23
24
  // );
24
25
  const items = useChildren(location);
26
+
27
+ React.useEffect(() => {
28
+ const filteredItems = items.filter((item) =>
29
+ types.length ? types.includes(item['@type']) : item,
30
+ );
31
+ if (filteredItems.length) setShowChildren(true);
32
+ }, [items, setShowChildren, types]);
33
+
25
34
  return (
26
35
  <div className="dataset-content">
27
36
  <div>