diff --git a/.github/workflows/dev-build.yaml b/.github/workflows/dev-build.yaml
index 6b53ebf3..3610d638 100644
--- a/.github/workflows/dev-build.yaml
+++ b/.github/workflows/dev-build.yaml
@@ -6,7 +6,7 @@ concurrency:
on:
push:
- branches: ["web-push-notifications-bootstrap"] # put your current branch to create a build. Core team only.
+ branches: ["4963-sidebar-selection-srcoll-into-view"] # put your current branch to create a build. Core team only.
paths-ignore:
- "**.md"
- "cloud-deployments/*"
diff --git a/frontend/src/components/SettingsSidebar/MenuOption/index.jsx b/frontend/src/components/SettingsSidebar/MenuOption/index.jsx
index 9b189ff9..ac7955da 100644
--- a/frontend/src/components/SettingsSidebar/MenuOption/index.jsx
+++ b/frontend/src/components/SettingsSidebar/MenuOption/index.jsx
@@ -2,6 +2,7 @@ import React, { useEffect, useState } from "react";
import { CaretRight } from "@phosphor-icons/react";
import { Link, useLocation } from "react-router-dom";
import { safeJsonParse } from "@/utils/request";
+import useScrollActiveItemIntoView from "@/hooks/useScrollActiveItemIntoView";
export default function MenuOption({
btnText,
@@ -25,6 +26,18 @@ export default function MenuOption({
location: location.pathname,
});
+ const isActive = hasChildren
+ ? (!isExpanded &&
+ childOptions.some((child) => child.href === location.pathname)) ||
+ location.pathname === href
+ : location.pathname === href;
+
+ const { ref } = useScrollActiveItemIntoView({
+ isActive,
+ behavior: "instant",
+ block: "center",
+ });
+
if (hidden) return null;
// If this option is a parent level option
@@ -43,12 +56,6 @@ export default function MenuOption({
if (flex && !!user && !roles.includes(user?.role)) return null;
}
- const isActive = hasChildren
- ? (!isExpanded &&
- childOptions.some((child) => child.href === location.pathname)) ||
- location.pathname === href
- : location.pathname === href;
-
const handleClick = (e) => {
if (hasChildren) {
e.preventDefault();
@@ -73,6 +80,7 @@ export default function MenuOption({
`}
>
) : (
}} An object containing the ref to attach to the target element.
+ */
+export default function useScrollActiveItemIntoView({
+ isActive,
+ behavior,
+ block,
+}) {
+ const ref = useRef(null);
+
+ useEffect(() => {
+ if (isActive) {
+ ref.current.scrollIntoView({
+ behavior,
+ block,
+ });
+ }
+ }, [isActive]);
+
+ return {
+ ref,
+ };
+}