File tree Expand file tree Collapse file tree 2 files changed +25
-6
lines changed
Expand file tree Collapse file tree 2 files changed +25
-6
lines changed Original file line number Diff line number Diff line change 1+ <script lang =" ts" >
2+ import { beforeNavigate } from " $app/navigation" ;
3+
4+ let lastPathname: string | null = null ;
5+
6+ beforeNavigate (({ from , to }) => {
7+ if (from ?.url && to ?.url ) {
8+ lastPathname = from .url .pathname ;
9+ sessionStorage .setItem (" lastPathname" , lastPathname );
10+ }
11+ });
12+ </script >
13+
114<div class =" layout-container" >
215 <slot />
316</div >
Original file line number Diff line number Diff line change 2626 let notifications: NotificationGroup [] | undefined = undefined ;
2727
2828 let pageTitle = getContext <Writable <string >>(" pageTitle" );
29+
30+ const handleBack = () => {
31+ const lastPathname = sessionStorage .getItem (" lastPathname" );
32+ const currentPathname = $page .url .pathname ;
33+
34+ if (! lastPathname || lastPathname === currentPathname ) {
35+ goto (" /app/home" );
36+ } else {
37+ goto (lastPathname );
38+ }
39+ };
2940 </script >
3041
3142<header
3546 <div class =" w-16" >
3647 <!-- svelte-ignore a11y_consider_explicit_label -->
3748 <button
38- on:click ={canGoBack
39- ? () =>
40- window .history .length > 1
41- ? window .history .back ()
42- : goto (" /app/home" )
43- : undefined }
49+ on:click ={canGoBack ? handleBack : undefined }
4450 class:opacity- 0={!canGoBack }
4551 class =" -m-4 p-4"
4652 >
You can’t perform that action at this time.
0 commit comments