@eeacms/volto-tabs-block 9.0.2 → 9.1.0

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,20 @@ 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
- ### [9.0.2](https://github.com/eea/volto-tabs-block/compare/9.0.1...9.0.2) - 27 January 2025
7
+ ### [9.1.0](https://github.com/eea/volto-tabs-block/compare/9.0.3...9.1.0) - 24 July 2025
8
+
9
+ #### :hammer_and_wrench: Others
10
+
11
+ - Release 9.1.0 [Alin Voinea - [`4396e37`](https://github.com/eea/volto-tabs-block/commit/4396e3740694d99cbb66414783c3fbbef7ed2022)]
12
+ ### [9.0.3](https://github.com/eea/volto-tabs-block/compare/9.0.2...9.0.3) - 7 May 2025
8
13
 
9
14
  #### :bug: Bug Fixes
10
15
 
11
- - fix: add BlockHasValue check on all child items instead one refs#282712 [nileshgulia1 - [`6c97620`](https://github.com/eea/volto-tabs-block/commit/6c9762054bdccef12c225bf3ac3daca50aca62dd)]
16
+ - fix: Active tab when navigation from within - refs #287006 [Nilesh - [`5133d07`](https://github.com/eea/volto-tabs-block/commit/5133d07b1fcf9fef8b336ea27a679d4aea594513)]
17
+
18
+ #### :hammer_and_wrench: Others
19
+
20
+ ### [9.0.2](https://github.com/eea/volto-tabs-block/compare/9.0.1...9.0.2) - 27 January 2025
12
21
 
13
22
  #### :house: Internal changes
14
23
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-tabs-block",
3
- "version": "9.0.2",
3
+ "version": "9.1.0",
4
4
  "description": "volto-tabs-block: Volto add-on",
5
5
  "main": "src/index.js",
6
6
  "author": "European Environment Agency: IDM2 A-Team",
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React, { useCallback, useEffect, useMemo } from 'react';
2
2
  import cx from 'classnames';
3
3
  import { compose } from 'redux';
4
4
  import { withRouter } from 'react-router';
@@ -39,32 +39,34 @@ const View = (props) => {
39
39
 
40
40
  const TabsView = activeVariation?.[0]?.view || DefaultView;
41
41
 
42
- const query = React.useMemo(() => {
42
+ const query = useMemo(() => {
43
43
  const { search } = location;
44
44
 
45
45
  return new URLSearchParams(search);
46
46
  }, [location]);
47
- const activeTabId = query.get('activeTab');
47
+ const activeTabId = useMemo(() => query.get('activeTab'), [query]);
48
48
 
49
- const addQueryParam = (key, value) => {
50
- const searchParams = new URLSearchParams(location.search);
51
- searchParams.set(key, value);
49
+ const handleActiveTabChange = useCallback(
50
+ (id) => {
51
+ const searchParams = new URLSearchParams(location.search);
52
+ searchParams.set('activeTab', id);
52
53
 
53
- history.push({
54
- pathname: location.pathname,
55
- search: searchParams.toString(),
56
- });
57
- };
58
-
59
- const handleActiveTabChange = (id) => {
60
- setActiveTab(id);
61
- addQueryParam('activeTab', id);
62
- };
54
+ history.push({
55
+ pathname: location.pathname,
56
+ search: searchParams.toString(),
57
+ });
58
+ setActiveTab(id);
59
+ },
60
+ [history, location],
61
+ );
63
62
 
64
- React.useEffect(() => {
63
+ useEffect(() => {
65
64
  if (tabsList.includes(activeTabId)) {
66
65
  setActiveTab(activeTabId);
67
66
  }
67
+ }, [activeTabId, tabsList]);
68
+
69
+ useEffect(() => {
68
70
  const urlHash = props.location.hash.substring(1) || '';
69
71
  const parentTabId = getParentTabFromHash(data, urlHash);
70
72
  const id = parentTabId;
@@ -34,6 +34,11 @@ jest.mock('react-router', () => ({
34
34
  },
35
35
  }));
36
36
 
37
+ // ENOENT: no such file or directory, open 'node:crypto'
38
+ jest.mock('uuid', () => ({
39
+ v4: () => 'test-uuid-1234',
40
+ }));
41
+
37
42
  jest.mock('@eeacms/volto-block-style/StyleWrapper', () => ({
38
43
  StyleWrapperView: (props) => {
39
44
  return <div className="mocked-style-wrapper">{props.children}</div>;
@@ -51,14 +56,14 @@ describe('View Component', () => {
51
56
  it('Should render and switch Tabs', () => {
52
57
  const customTabsData = {
53
58
  blocks_layout: {
54
- items: ['tab1', 'tab2', 'tab3'],
59
+ items: ['test-uuid-1234', 'test-uuid-5678', 'tab3'],
55
60
  },
56
61
  blocks: {
57
- tab1: {
62
+ 'test-uuid-1234': {
58
63
  title: 'Tab 1 Title',
59
64
  content: 'Tab 1 Content',
60
65
  },
61
- tab2: {
66
+ 'test-uuid-5678': {
62
67
  title: 'Tab 2 Title',
63
68
  content: 'Tab 2 Content',
64
69
  },
@@ -248,6 +248,7 @@ const Edit = (props) => {
248
248
  allowedBlocks={data?.allowedBlocks}
249
249
  description={data?.instructions?.data}
250
250
  manage={manage}
251
+ isMainForm={false}
251
252
  metadata={metadata}
252
253
  pathname={props.pathname}
253
254
  properties={isEmpty(tabs[tab]) ? emptyBlocksForm() : tabs[tab]}
@@ -351,6 +351,7 @@ const Edit = (props) => {
351
351
  allowedBlocks={data?.allowedBlocks}
352
352
  description={data?.instructions?.data}
353
353
  manage={manage}
354
+ isMainForm={false}
354
355
  metadata={metadata}
355
356
  pathname={props.pathname}
356
357
  properties={isEmpty(tabs[tab]) ? emptyBlocksForm() : tabs[tab]}