volto-dropdownmenu 2.4.0 → 2.4.3
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,40 @@ 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
|
+
#### [v2.4.3](https://github.com/collective/volto-dropdownmenu/compare/v2.4.3...v2.4.3)
|
|
8
|
+
|
|
9
|
+
> 31 August 2022
|
|
10
|
+
|
|
11
|
+
- fix: a11y handle dropdown navigation [`67e97c1`](https://github.com/collective/volto-dropdownmenu/commit/67e97c1947e6a392e82c3104b5797a9c7680812f)
|
|
12
|
+
- chore: rollback 2.4.3 release [`07b437b`](https://github.com/collective/volto-dropdownmenu/commit/07b437b365aaabc5a05e4d7adb7086f50186b3bc)
|
|
13
|
+
|
|
14
|
+
#### [v2.4.3](https://github.com/collective/volto-dropdownmenu/compare/v2.4.2...v2.4.3)
|
|
15
|
+
|
|
16
|
+
> 31 August 2022
|
|
17
|
+
|
|
18
|
+
- fix: a11y handle dropdown navigation [`b8304c1`](https://github.com/collective/volto-dropdownmenu/commit/b8304c1990698e0c957679edadeb58a18ffc539d)
|
|
19
|
+
- Release 2.4.3 [`b0f92e7`](https://github.com/collective/volto-dropdownmenu/commit/b0f92e7af65952ae5bcff29bde97c3edb9edf6af)
|
|
20
|
+
|
|
21
|
+
#### [v2.4.2](https://github.com/collective/volto-dropdownmenu/compare/v2.4.1...v2.4.2)
|
|
22
|
+
|
|
23
|
+
> 25 May 2022
|
|
24
|
+
|
|
25
|
+
- Release 2.4.2 [`0cb2f7c`](https://github.com/collective/volto-dropdownmenu/commit/0cb2f7c2faf7735f44e9f37764c821f7b7ddd8b0)
|
|
26
|
+
- feat: added mobile-menu-opend class to body when mobile menu is opened [`659960c`](https://github.com/collective/volto-dropdownmenu/commit/659960c07782af2b0fe7d0686029bfea2ee0bac2)
|
|
27
|
+
|
|
28
|
+
#### [v2.4.1](https://github.com/collective/volto-dropdownmenu/compare/v2.4.0...v2.4.1)
|
|
29
|
+
|
|
30
|
+
> 14 March 2022
|
|
31
|
+
|
|
32
|
+
- Release 2.4.1 [`4fa2990`](https://github.com/collective/volto-dropdownmenu/commit/4fa2990e03ed41d2dddc5f7fecc6b271c2c356f6)
|
|
33
|
+
- chore: added close event on clickableNavigationRoots [`2cc495a`](https://github.com/collective/volto-dropdownmenu/commit/2cc495a7bd8db9dd6fd90dcafcf31ca31a06c2e8)
|
|
34
|
+
|
|
7
35
|
#### [v2.4.0](https://github.com/collective/volto-dropdownmenu/compare/v2.3.0...v2.4.0)
|
|
8
36
|
|
|
9
37
|
> 4 March 2022
|
|
10
38
|
|
|
11
39
|
- feat: added clickableNavigationRoots configurable option [`4f75f3b`](https://github.com/collective/volto-dropdownmenu/commit/4f75f3b8e1714b2e159bfe964d8ff7ca0bf445a9)
|
|
40
|
+
- Release 2.4.0 [`d20252a`](https://github.com/collective/volto-dropdownmenu/commit/d20252adb03fc04beb05a8189d51dd166eb8c6b8)
|
|
12
41
|
- fix: fix hasBlocks data if has only one empty text block [`584f6a2`](https://github.com/collective/volto-dropdownmenu/commit/584f6a280e38c8f2f589acb18534c8ca5d8163af)
|
|
13
42
|
- fix: fixed readme [`d16175a`](https://github.com/collective/volto-dropdownmenu/commit/d16175a99a68c6bc33c4b102f44d2479a30fafca)
|
|
14
43
|
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useEffect } from 'react';
|
|
2
2
|
import { NavLink, useLocation } from 'react-router-dom';
|
|
3
3
|
import { defineMessages, useIntl } from 'react-intl';
|
|
4
4
|
import { Segment, Container, Icon, Grid, Button } from 'semantic-ui-react';
|
|
@@ -48,6 +48,24 @@ const DropdownMenu = ({ menu, open = false, closeMenu }) => {
|
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
+
const lastLinkEventListener = (e) => {
|
|
52
|
+
if (e.code === 'Tab') {
|
|
53
|
+
document
|
|
54
|
+
.querySelector(
|
|
55
|
+
'.dropdown-menu-wrapper.open button.dropdown-close-button',
|
|
56
|
+
)
|
|
57
|
+
.focus();
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
useEffect(() => {
|
|
62
|
+
const links = document.querySelectorAll('.dropdown-menu-wrapper.open a');
|
|
63
|
+
const lastLink = links[links.length - 1];
|
|
64
|
+
if (lastLink) {
|
|
65
|
+
lastLink.addEventListener('keydown', lastLinkEventListener);
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
|
|
51
69
|
return (
|
|
52
70
|
<div
|
|
53
71
|
className={cx('dropdown-menu-wrapper', {
|
|
@@ -70,7 +70,7 @@ const Navigation = ({ pathname, type }) => {
|
|
|
70
70
|
const targetItem = getAnchorTarget(e.target);
|
|
71
71
|
const dropdownmenuLinks = [
|
|
72
72
|
...(document?.querySelectorAll(
|
|
73
|
-
'.navigation-dropdownmenu .dropdown-menu-wrapper ul li a, .navigation-dropdownmenu .dropdownmenu-blocks-column a, .dropdownmenu-footer a, .navigation-dropdownmenu .menu > a',
|
|
73
|
+
'.navigation-dropdownmenu .dropdown-menu-wrapper ul li a, .navigation-dropdownmenu .dropdown-menu-wrapper h2 a, .navigation-dropdownmenu .dropdownmenu-blocks-column a, .dropdownmenu-footer a, .navigation-dropdownmenu .menu > a',
|
|
74
74
|
) ?? []),
|
|
75
75
|
];
|
|
76
76
|
|
|
@@ -88,6 +88,14 @@ const Navigation = ({ pathname, type }) => {
|
|
|
88
88
|
return () => document.body.removeEventListener('click', clickListener);
|
|
89
89
|
}, []);
|
|
90
90
|
|
|
91
|
+
useEffect(() => {
|
|
92
|
+
if (isMobileMenuOpen) {
|
|
93
|
+
document.body.classList.add('mobile-menu-opened'); //to prevent scroll body
|
|
94
|
+
} else {
|
|
95
|
+
document.body.classList.remove('mobile-menu-opened'); //re-enable scroll body
|
|
96
|
+
}
|
|
97
|
+
}, [isMobileMenuOpen]);
|
|
98
|
+
|
|
91
99
|
const toggleMobileMenu = () => {
|
|
92
100
|
setMobileMenuOpen(!isMobileMenuOpen);
|
|
93
101
|
};
|