Skip to content

Commit

Permalink
#64 fix: breadcrumb menu never closes
Browse files Browse the repository at this point in the history
  • Loading branch information
emekauja committed Nov 15, 2022
1 parent 4372099 commit c560075
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions src/components/common/Breadcrumbs.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
Box,
ClickAwayListener,
IconButton,
Link,
MenuItem,
Expand Down Expand Up @@ -114,8 +115,11 @@ export const CustomBreadcrumbsWithMenu = ({ breadcrumbs }) => {
const collapsed = !!breadcrumbs && breadcrumbs.length > 5;

const handleClick = (event) => {
if (event) {
console.log('running e ===');
if (event && anchorEl === null) {
setAnchorEl(event.currentTarget);
} else if (anchorEl !== null) {
setAnchorEl(null);
}
};

Expand Down Expand Up @@ -161,15 +165,20 @@ export const CustomBreadcrumbsWithMenu = ({ breadcrumbs }) => {
placement="bottom"
aria-labelledby="with-menu-breadcrumbs"
>
{collapsedCrumbs && collapsedCrumbs.length > 1
? collapsedCrumbs.map((crumb) => (
<MenuItem onClick={handleClose} key={crumb.id}>
{crumb.text}
</MenuItem>
))
: null}
<ClickAwayListener onClickAway={handleClose}>
<Box>
{collapsedCrumbs && collapsedCrumbs.length > 1
? collapsedCrumbs.map((crumb) => (
<MenuItem onClick={handleClose} key={crumb.id}>
{crumb.text}
</MenuItem>
))
: null}
</Box>
</ClickAwayListener>
</Popper>
)}
)}

<Breadcrumbs
aria-label="breadcrumbs"
maxItems={_breadcrumbs.length}
Expand Down

0 comments on commit c560075

Please sign in to comment.