Skip to content

Commit

Permalink
fix: back to last location
Browse files Browse the repository at this point in the history
Signed-off-by: Innei <i@innei.in>
  • Loading branch information
Innei committed Jul 24, 2024
1 parent 51db2dc commit 15f7022
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/renderer/src/pages/(main)/(layer)/(subview)/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
import { getReadonlyRoute } from "@renderer/atoms/route"
import {
getSidebarActiveView,
setSidebarActiveView,
} from "@renderer/atoms/sidebar"
import { MotionButtonBase } from "@renderer/components/ui/button"
import { useRef } from "react"
import { Outlet, useNavigate } from "react-router-dom"

export function Component() {
const navigate = useNavigate()
const prevLocation = useRef(getReadonlyRoute().location).current
const prevView = useRef(getSidebarActiveView()).current
return (
<div className="relative flex size-full">
<MotionButtonBase
onClick={() => navigate("/")}
onClick={() => {
navigate(prevLocation)

setSidebarActiveView(prevView)
}}
className="absolute left-10 top-11 flex items-center gap-1"
>
<i className="i-mgc-left-cute-fi" />
Expand Down
1 change: 1 addition & 0 deletions src/renderer/src/providers/stable-router-provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,6 @@ export const StableRouterProvider = () => {
})
}
}, [location, searchParams])

return null
}

0 comments on commit 15f7022

Please sign in to comment.