Skip to content

Commit

Permalink
fix(graph): fix scrolling to take group header height into account
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxKless committed Jul 23, 2024
1 parent 1469b26 commit ba59f18
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ export function TargetConfigurationGroupContainer({
return null;
}
return (
<div className="mb-4 w-full">
<div
id={`target-group-container-${targetGroupName}`}
className="mb-4 w-full"
>
<TargetConfigurationGroupHeader
targetGroupName={targetGroupName}
targetsNumber={targetsNumber}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const TargetConfigurationGroupHeader = ({
}: TargetConfigurationGroupHeaderProps) => {
return (
<header
id={`target-group-header-${targetGroupName}`}
className={`flex items-center gap-2 px-4 py-2 text-lg capitalize ${className}`}
>
{targetGroupName}{' '}
Expand Down
8 changes: 7 additions & 1 deletion nx-dev/ui-markdoc/src/lib/tags/project-details.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,16 @@ export function ProjectDetails({
const header = document.getElementById('target-' + expandedTargets[0]);
const container = document.getElementById('project-details-container');
if (header && container) {
const groupHeaderOffset =
header
.closest('[id^="target-group-container-"]')
?.querySelector('[id^="target-group-header-"]')
?.getBoundingClientRect().height ?? 0;
elementRef.current?.scrollTo({
top:
header?.getBoundingClientRect().top -
container.getBoundingClientRect()?.top,
container.getBoundingClientRect()?.top -
groupHeaderOffset,
behavior: 'instant',
});
}
Expand Down

0 comments on commit ba59f18

Please sign in to comment.