@carbon-labs/react-ui-shell 0.45.0 → 0.47.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/es/components/SideNav.js
CHANGED
|
@@ -157,6 +157,7 @@ function SideNavRenderFunction(_ref, ref) {
|
|
|
157
157
|
const backButton = sideNavRef?.current.querySelector(`.${prefix}--side-nav__back-button`);
|
|
158
158
|
const slotElement = sideNavRef?.current.querySelector(`.${prefix}--side-nav__slot`);
|
|
159
159
|
const firstElement = sideNavRef?.current?.querySelector('a, button');
|
|
160
|
+
const currentElement = sideNavRef?.current?.querySelector(`.cds--side-nav__link--current`);
|
|
160
161
|
if (navType == SIDE_NAV_TYPE.PANEL || expanded) {
|
|
161
162
|
if (isSm && backButton) {
|
|
162
163
|
backButton.tabIndex = 0;
|
|
@@ -164,6 +165,8 @@ function SideNavRenderFunction(_ref, ref) {
|
|
|
164
165
|
if (firstElementAfterBack) {
|
|
165
166
|
firstElementAfterBack.tabIndex = 0;
|
|
166
167
|
}
|
|
168
|
+
} else if (currentElement && currentElement.closest(`[id="${currentPrimaryMenu}"]`)) {
|
|
169
|
+
currentElement.tabIndex = 0;
|
|
167
170
|
} else if (firstElement) {
|
|
168
171
|
firstElement.tabIndex = 0;
|
|
169
172
|
if (slotElement) {
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { SideNavIcon,
|
|
8
|
+
import { SideNavIcon, Layer, Button } from '@carbon/react';
|
|
9
9
|
import { breakpoints } from '../node_modules/@carbon/layout/es/index.js';
|
|
10
10
|
import cx from '../_virtual/index.js';
|
|
11
11
|
import PropTypes from 'prop-types';
|
|
@@ -173,7 +173,7 @@ const SideNavMenu = /*#__PURE__*/React.forwardRef(function SideNavMenu(_ref, ref
|
|
|
173
173
|
return node;
|
|
174
174
|
}
|
|
175
175
|
function handleKeyDown(event) {
|
|
176
|
-
if (match(event, Escape)) {
|
|
176
|
+
if (match(event, Escape) && !primary) {
|
|
177
177
|
setIsExpanded(false);
|
|
178
178
|
if (onMenuToggle) {
|
|
179
179
|
onMenuToggle();
|
|
@@ -275,23 +275,21 @@ const SideNavMenu = /*#__PURE__*/React.forwardRef(function SideNavMenu(_ref, ref
|
|
|
275
275
|
setSecondaryOpen(isExpanded);
|
|
276
276
|
}, [isExpanded]);
|
|
277
277
|
useEffect(() => {
|
|
278
|
-
if (currentPrimaryMenu !== uniqueId) {
|
|
278
|
+
if (primary && currentPrimaryMenu !== uniqueId) {
|
|
279
279
|
setIsExpanded(false);
|
|
280
280
|
} else {
|
|
281
281
|
setIsExpanded(true);
|
|
282
282
|
}
|
|
283
283
|
}, [currentPrimaryMenu]);
|
|
284
|
-
|
|
285
|
-
// save expanded state before SideNav collapse
|
|
286
|
-
const [lastExpandedState, setLastExpandedState] = useState(isExpanded);
|
|
287
|
-
|
|
288
284
|
// reset to opened/collapsed menu state when Panel SideNav is toggled
|
|
289
285
|
useEffect(() => {
|
|
290
286
|
if (navType == SIDE_NAV_TYPE.PANEL && !sideNavExpanded) {
|
|
291
|
-
setLastExpandedState(isExpanded);
|
|
292
287
|
setIsExpanded(false);
|
|
293
|
-
}
|
|
294
|
-
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
// will always open to the menu with an active element
|
|
291
|
+
if (primary && (active || hasActiveDescendant(children))) {
|
|
292
|
+
setIsExpanded(true);
|
|
295
293
|
}
|
|
296
294
|
}, [sideNavExpanded]);
|
|
297
295
|
const [openPopover, setOpenPopover] = React.useState(false);
|
|
@@ -327,7 +325,6 @@ const SideNavMenu = /*#__PURE__*/React.forwardRef(function SideNavMenu(_ref, ref
|
|
|
327
325
|
// window.location.href = firstLink.current;
|
|
328
326
|
} else if (isSm || !primary || currentPrimaryMenu !== uniqueId) {
|
|
329
327
|
setIsExpanded(!isExpanded);
|
|
330
|
-
setLastExpandedState(!isExpanded);
|
|
331
328
|
}
|
|
332
329
|
if (isSm && backButtonRef.current) {
|
|
333
330
|
backButtonRef.current.focus();
|
|
@@ -349,7 +346,7 @@ const SideNavMenu = /*#__PURE__*/React.forwardRef(function SideNavMenu(_ref, ref
|
|
|
349
346
|
size: 20
|
|
350
347
|
})) : _ChevronDown || (_ChevronDown = /*#__PURE__*/React.createElement(ChevronDown, {
|
|
351
348
|
size: 20
|
|
352
|
-
})))), primary ? /*#__PURE__*/React.createElement("div", {
|
|
349
|
+
})))), primary ? /*#__PURE__*/React.createElement(Layer, null, /*#__PURE__*/React.createElement("div", {
|
|
353
350
|
className: primaryClassNames
|
|
354
351
|
}, /*#__PURE__*/React.createElement(SideNavItems, {
|
|
355
352
|
accessibilityLabel: {
|
|
@@ -362,7 +359,7 @@ const SideNavMenu = /*#__PURE__*/React.forwardRef(function SideNavMenu(_ref, ref
|
|
|
362
359
|
onClick: handleOnBackButtonClick,
|
|
363
360
|
className: `${prefix}--side-nav__back-button`,
|
|
364
361
|
renderIcon: backButtonRenderIcon
|
|
365
|
-
}, backButtonTitle),
|
|
362
|
+
}, backButtonTitle), childrenToRender))) : /*#__PURE__*/React.createElement("ul", {
|
|
366
363
|
className: `${prefix}--side-nav__menu`,
|
|
367
364
|
role: "group"
|
|
368
365
|
}, childrenToRender));
|
|
@@ -159,6 +159,7 @@ function SideNavRenderFunction(_ref, ref) {
|
|
|
159
159
|
const backButton = sideNavRef?.current.querySelector(`.${prefix}--side-nav__back-button`);
|
|
160
160
|
const slotElement = sideNavRef?.current.querySelector(`.${prefix}--side-nav__slot`);
|
|
161
161
|
const firstElement = sideNavRef?.current?.querySelector('a, button');
|
|
162
|
+
const currentElement = sideNavRef?.current?.querySelector(`.cds--side-nav__link--current`);
|
|
162
163
|
if (navType == SIDE_NAV_TYPE.PANEL || expanded) {
|
|
163
164
|
if (isSm && backButton) {
|
|
164
165
|
backButton.tabIndex = 0;
|
|
@@ -166,6 +167,8 @@ function SideNavRenderFunction(_ref, ref) {
|
|
|
166
167
|
if (firstElementAfterBack) {
|
|
167
168
|
firstElementAfterBack.tabIndex = 0;
|
|
168
169
|
}
|
|
170
|
+
} else if (currentElement && currentElement.closest(`[id="${currentPrimaryMenu}"]`)) {
|
|
171
|
+
currentElement.tabIndex = 0;
|
|
169
172
|
} else if (firstElement) {
|
|
170
173
|
firstElement.tabIndex = 0;
|
|
171
174
|
if (slotElement) {
|
|
@@ -175,7 +175,7 @@ const SideNavMenu = /*#__PURE__*/React.forwardRef(function SideNavMenu(_ref, ref
|
|
|
175
175
|
return node;
|
|
176
176
|
}
|
|
177
177
|
function handleKeyDown(event) {
|
|
178
|
-
if (match.match(event, keys.Escape)) {
|
|
178
|
+
if (match.match(event, keys.Escape) && !primary) {
|
|
179
179
|
setIsExpanded(false);
|
|
180
180
|
if (onMenuToggle) {
|
|
181
181
|
onMenuToggle();
|
|
@@ -277,23 +277,21 @@ const SideNavMenu = /*#__PURE__*/React.forwardRef(function SideNavMenu(_ref, ref
|
|
|
277
277
|
setSecondaryOpen(isExpanded);
|
|
278
278
|
}, [isExpanded]);
|
|
279
279
|
React.useEffect(() => {
|
|
280
|
-
if (currentPrimaryMenu !== uniqueId) {
|
|
280
|
+
if (primary && currentPrimaryMenu !== uniqueId) {
|
|
281
281
|
setIsExpanded(false);
|
|
282
282
|
} else {
|
|
283
283
|
setIsExpanded(true);
|
|
284
284
|
}
|
|
285
285
|
}, [currentPrimaryMenu]);
|
|
286
|
-
|
|
287
|
-
// save expanded state before SideNav collapse
|
|
288
|
-
const [lastExpandedState, setLastExpandedState] = React.useState(isExpanded);
|
|
289
|
-
|
|
290
286
|
// reset to opened/collapsed menu state when Panel SideNav is toggled
|
|
291
287
|
React.useEffect(() => {
|
|
292
288
|
if (navType == SideNav.SIDE_NAV_TYPE.PANEL && !sideNavExpanded) {
|
|
293
|
-
setLastExpandedState(isExpanded);
|
|
294
289
|
setIsExpanded(false);
|
|
295
|
-
}
|
|
296
|
-
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
// will always open to the menu with an active element
|
|
293
|
+
if (primary && (active || hasActiveDescendant(children))) {
|
|
294
|
+
setIsExpanded(true);
|
|
297
295
|
}
|
|
298
296
|
}, [sideNavExpanded]);
|
|
299
297
|
const [openPopover, setOpenPopover] = React.useState(false);
|
|
@@ -329,7 +327,6 @@ const SideNavMenu = /*#__PURE__*/React.forwardRef(function SideNavMenu(_ref, ref
|
|
|
329
327
|
// window.location.href = firstLink.current;
|
|
330
328
|
} else if (isSm || !primary || currentPrimaryMenu !== uniqueId) {
|
|
331
329
|
setIsExpanded(!isExpanded);
|
|
332
|
-
setLastExpandedState(!isExpanded);
|
|
333
330
|
}
|
|
334
331
|
if (isSm && backButtonRef.current) {
|
|
335
332
|
backButtonRef.current.focus();
|
|
@@ -351,7 +348,7 @@ const SideNavMenu = /*#__PURE__*/React.forwardRef(function SideNavMenu(_ref, ref
|
|
|
351
348
|
size: 20
|
|
352
349
|
})) : _ChevronDown || (_ChevronDown = /*#__PURE__*/React.createElement(bucket3.ChevronDown, {
|
|
353
350
|
size: 20
|
|
354
|
-
})))), primary ? /*#__PURE__*/React.createElement("div", {
|
|
351
|
+
})))), primary ? /*#__PURE__*/React.createElement(react.Layer, null, /*#__PURE__*/React.createElement("div", {
|
|
355
352
|
className: primaryClassNames
|
|
356
353
|
}, /*#__PURE__*/React.createElement(SideNavItems.SideNavItems, {
|
|
357
354
|
accessibilityLabel: {
|
|
@@ -364,7 +361,7 @@ const SideNavMenu = /*#__PURE__*/React.forwardRef(function SideNavMenu(_ref, ref
|
|
|
364
361
|
onClick: handleOnBackButtonClick,
|
|
365
362
|
className: `${prefix}--side-nav__back-button`,
|
|
366
363
|
renderIcon: backButtonRenderIcon
|
|
367
|
-
}, backButtonTitle),
|
|
364
|
+
}, backButtonTitle), childrenToRender))) : /*#__PURE__*/React.createElement("ul", {
|
|
368
365
|
className: `${prefix}--side-nav__menu`,
|
|
369
366
|
role: "group"
|
|
370
367
|
}, childrenToRender));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@carbon-labs/react-ui-shell",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.47.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"provenance": true
|
|
@@ -41,5 +41,5 @@
|
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@ibm/telemetry-js": "^1.9.1"
|
|
43
43
|
},
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "36a0245024d07cce75ca5654c2070ab252f0ca8c"
|
|
45
45
|
}
|