33import React , { useState , useEffect } from "react" ;
44import { EyeIcon as Eye , CodeIcon as Code , BookOpenTextIcon as Book } from "@phosphor-icons/react" ;
55import { cn } from "@/lib/utils" ;
6- import { useRouter , usePathname } from "next/navigation" ;
6+ import { useRouter , usePathname , useSearchParams } from "next/navigation" ;
77import { DemoList } from "@/components/demo-list/demo-list" ;
88import { ThemeToggle } from "@/components/ui/theme-toggle" ;
99import { ChevronDown } from "lucide-react" ;
@@ -31,6 +31,7 @@ interface SidebarProps {
3131export function Sidebar ( { isMobile, onMobileClose } : SidebarProps ) {
3232 const router = useRouter ( ) ;
3333 const pathname = usePathname ( ) ;
34+ const searchParams = useSearchParams ( ) ;
3435 const { theme, setTheme } = useTheme ( ) ;
3536 const isDarkTheme = theme === "dark"
3637 const { view, frameworkPickerHidden, viewPickerHidden, featurePickerHidden, setView} = useURLParams ( ) ;
@@ -56,7 +57,10 @@ export function Sidebar({ isMobile, onMobileClose }: SidebarProps) {
5657 // Handle selecting a demo
5758 const handleDemoSelect = ( demoId : string ) => {
5859 if ( currentIntegration ) {
59- router . push ( `/${ currentIntegration . id } /feature/${ demoId } ` ) ;
60+ const queryString = searchParams . toString ( ) ;
61+ const newPath = `/${ currentIntegration . id } /feature/${ demoId } ` ;
62+ const url = queryString ? `${ newPath } ?${ queryString } ` : newPath ;
63+ router . push ( url ) ;
6064 // Close mobile sidebar when demo is selected
6165 if ( isMobile && onMobileClose ) {
6266 onMobileClose ( ) ;
@@ -66,7 +70,10 @@ export function Sidebar({ isMobile, onMobileClose }: SidebarProps) {
6670
6771 // Handle integration selection
6872 const handleIntegrationSelect = ( integrationId : string ) => {
69- router . push ( `/${ integrationId } ` ) ;
73+ const queryString = searchParams . toString ( ) ;
74+ const newPath = `/${ integrationId } ` ;
75+ const url = queryString ? `${ newPath } ?${ queryString } ` : newPath ;
76+ router . push ( url ) ;
7077 } ;
7178
7279 const tabClass = `cursor-pointer flex-1 h-8 px-2 text-sm text-primary shadow-none bg-none border-none font-medium gap-1 rounded-lg data-[state=active]:bg-white data-[state=active]:text-primary data-[state=active]:shadow-none`
0 commit comments