Skip to content

Commit

Permalink
Scroll active sidebar item into view
Browse files Browse the repository at this point in the history
  • Loading branch information
fatonramadani committed Sep 28, 2023
1 parent 8c882e8 commit 9a67bad
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
13 changes: 7 additions & 6 deletions docs/core_concepts/14_audit_logs/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,20 @@ Audit Logs can be filtered by Date, Username, Action (Create, Update, Delete, Ex
src="/videos/audit_logs.mp4"
/>

<br/>
<br />

<div class="grid grid-cols-2 gap-6 mb-4">
<DocCard
title="Runs Menu"
description="The Runs menu is another feature that allows you to visualise all past and future runs."
href="/docs/core_concepts/audit_logs"
/>
<DocCard
title="Runs Menu"
description="The Runs menu is another feature that allows you to visualise all past and future runs."
href="/docs/core_concepts/monitor_past_and_future_runs"
/>
</div>

## Retention Policy

The retention policy for audit logs varies depending on your team's plan:

- Community plan: Audit logs are redacted.
- Team plan (cloud): Audit logs are retained for 7 days.
- Enterprise plan (cloud): Audit logs are retained for 60 days.
Expand Down
14 changes: 13 additions & 1 deletion src/theme/DocSidebarItem/Link/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { useEffect, useRef } from 'react';
import clsx from 'clsx';
import { ThemeClassNames } from '@docusaurus/theme-common';
import { isActiveSidebarItem } from '@docusaurus/theme-common/internal';
Expand All @@ -14,9 +14,20 @@ export default function DocSidebarItemLink({
index,
...props
}) {
const activeItemRef = useRef(null);
const { href, label, className, autoAddBaseUrl } = item;
const isActive = isActiveSidebarItem(item, activePath);
const isInternalLink = isInternalUrl(href);

useEffect(() => {
if (isActive && activeItemRef.current) {
activeItemRef.current.scrollIntoView({
behavior: 'smooth',
block: 'nearest'
});
}
}, [isActive]);

return (
<li
className={clsx(
Expand All @@ -28,6 +39,7 @@ export default function DocSidebarItemLink({
key={label}
>
<Link
ref={isActive ? activeItemRef : null}
className={clsx(
'menu__link',
!isInternalLink && styles.menuExternalLink,
Expand Down

0 comments on commit 9a67bad

Please sign in to comment.