Skip to content

Commit

Permalink
fix/dropdown breadcrumbs (#799)
Browse files Browse the repository at this point in the history
fix: dropdown breadcrumbs

Signed-off-by: Soham Parekh <[email protected]>
Co-authored-by: Soham Parekh <[email protected]>
  • Loading branch information
4nalog and Soham Parekh authored Jul 19, 2023
1 parent 74840f8 commit b1144f2
Showing 1 changed file with 21 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,26 +86,24 @@ const BreadcrumbPopOver = (props: BreadcrumbPopoverInterface) => {
/**
* Handle the callback to close the popover and navigate to the url
*/
const handleLink =
(e, url: string, isActive = false) =>
() => {
e.preventDefault();
e.stopPropagation();
const handleLink = (e, url: string, isActive = false) => {
e.preventDefault();
e.stopPropagation();

if (props.id.startsWith('project') || props.id.startsWith('domain')) {
const projectDomain: LocalStorageProjectDomain = {
domain: props.domainId,
project: props.projectId,
};
setLocalStore(LOCAL_PROJECT_DOMAIN, projectDomain);
}
if (props.id.startsWith('project') || props.id.startsWith('domain')) {
const projectDomain: LocalStorageProjectDomain = {
domain: props.domainId,
project: props.projectId,
};
setLocalStore(LOCAL_PROJECT_DOMAIN, projectDomain);
}

if (!isActive) {
history.push(url);
props.onClose();
return;
}
};
if (!isActive) {
history.push(url);
props.onClose();
return;
}
};

const styles = makeStyles(theme => ({
wrapper: {
Expand Down Expand Up @@ -170,13 +168,13 @@ const BreadcrumbPopOver = (props: BreadcrumbPopoverInterface) => {
<ListItem
key={data.title}
button
onClick={e =>
onClick={e => {
handleLink(
e,
data.url,
activeBasedOnTitle || activeBasedOnAsyncData,
)
}
);
}}
className={`breadcrumb-form-control-popover-list-item ${
activeBasedOnTitle || activeBasedOnAsyncData
? 'active'
Expand Down Expand Up @@ -218,38 +216,11 @@ const BreadcrumbPopOver = (props: BreadcrumbPopoverInterface) => {
</>
)}
</Grid>
<Grid item>
<Link
onClick={e =>
handleLink(
e,
data.url,
activeBasedOnTitle || activeBasedOnAsyncData,
)
}
href={data.url}
>
{data?.title || 'name not found'}
</Link>
</Grid>
<Grid item>{data?.title || 'name not found'}</Grid>
{data?.createdAt && (
<>
<Grid item>|</Grid>
<Grid item>
<Link
onClick={e =>
handleLink(
e,
data.url,
activeBasedOnTitle ||
activeBasedOnAsyncData,
)
}
href={data.url}
>
{data.createdAt}
</Link>
</Grid>
<Grid item>{data.createdAt}</Grid>
</>
)}
</Grid>
Expand Down

0 comments on commit b1144f2

Please sign in to comment.