gatsby-theme-carbon 4.1.6 → 4.1.7
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/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { memo, useCallback, useEffect, useState } from 'react';
|
|
2
2
|
import { useLocation } from '@reach/router';
|
|
3
3
|
import { Theme, TreeNode, TreeView } from '@carbon/react';
|
|
4
|
-
import { Link } from 'gatsby';
|
|
4
|
+
import { Link, navigate } from 'gatsby';
|
|
5
5
|
|
|
6
6
|
import cx from 'classnames';
|
|
7
7
|
import slugify from 'slugify';
|
|
@@ -110,6 +110,13 @@ const LeftNavTree = ({ items, theme, pathPrefix }) => {
|
|
|
110
110
|
evalNode.pages?.some((page) => page.id === treeActiveItem?.id)
|
|
111
111
|
);
|
|
112
112
|
|
|
113
|
+
const handleKeyDownEvent = (event, path) => {
|
|
114
|
+
if (event.key === 'Enter' || event.key === ' ') {
|
|
115
|
+
event.preventDefault();
|
|
116
|
+
navigate(path);
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
|
|
113
120
|
function renderTree({ nodes }) {
|
|
114
121
|
if (!nodes) {
|
|
115
122
|
return;
|
|
@@ -136,6 +143,7 @@ const LeftNavTree = ({ items, theme, pathPrefix }) => {
|
|
|
136
143
|
label={label}
|
|
137
144
|
value={node.title}
|
|
138
145
|
isExpanded={isTreeNodeExpanded(node)}
|
|
146
|
+
onKeyDown={(event) => handleKeyDownEvent(event, node.path)}
|
|
139
147
|
className={cx({
|
|
140
148
|
'cds--tree-node--active': node.id === treeActiveItem?.id,
|
|
141
149
|
'cds--tree-node--selected': node.id === treeActiveItem?.id,
|