Skip to content

Commit

Permalink
change nav hierarchy for stateful cloud to use panelOpener
Browse files Browse the repository at this point in the history
  • Loading branch information
mgiota committed Sep 13, 2024
1 parent de454fe commit 34f378e
Show file tree
Hide file tree
Showing 3 changed files with 188 additions and 225 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -274,11 +274,6 @@ function validateNodeProps<
`[Chrome navigation] Error in node [${id}]. Only one of "href" or "cloudLink" can be provided.`
);
}
if (renderAs === 'panelOpener' && !link) {
throw new Error(
`[Chrome navigation] Error in node [${id}]. If renderAs is set to "panelOpener", a "link" must also be provided.`
);
}
if (renderAs === 'item' && !link && !onClick) {
throw new Error(
`[Chrome navigation] Error in node [${id}]. If renderAs is set to "item", a "link" or "onClick" must also be provided.`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,18 @@ export const NavigationItemOpenPanel: FC<Props> = ({ item, navigateToUrl, active
const onLinkClick = useCallback(
(e: React.MouseEvent) => {
if (!href) {
if (selectedNode?.id === item.id) {
closePanel();
} else {
openPanel(item);
}
return;
}
e.preventDefault();
navigateToUrl(href);
closePanel();
},
[closePanel, href, navigateToUrl]
[closePanel, href, item, navigateToUrl, openPanel, selectedNode]
);

const onIconClick = useCallback(() => {
Expand Down Expand Up @@ -123,7 +128,7 @@ export const NavigationItemOpenPanel: FC<Props> = ({ item, navigateToUrl, active
size="s"
color="text"
onClick={onIconClick}
iconType="spaces"
iconType="arrowRight"
iconSize="m"
aria-label={i18n.translate('sharedUXPackages.chrome.sideNavigation.togglePanel', {
defaultMessage: 'Toggle "{title}" panel navigation',
Expand Down
Loading

0 comments on commit 34f378e

Please sign in to comment.