Exiting settings should navigate to previous location (#1467)
**Summary:** Updated `SettingsLayout.tsx` to simplify the `handleBack` function - now it always uses `navigate(-1)` to go back in browser history. This means pressing ESC (or clicking the X button) in Settings will return users to whatever page they came from. Removed the unused `useLocation` import as it was no longer needed.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { NavLink, Outlet, useNavigate, useLocation } from 'react-router-dom';
|
||||
import { NavLink, Outlet, useNavigate } from 'react-router-dom';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Settings, Cpu, Server, X, FolderOpen, Building2 } from 'lucide-react';
|
||||
import { cn } from '@/lib/utils';
|
||||
@@ -44,14 +44,9 @@ export function SettingsLayout() {
|
||||
}, [enableScope, disableScope]);
|
||||
|
||||
const navigate = useNavigate();
|
||||
const location = useLocation();
|
||||
|
||||
const handleBack = () => {
|
||||
if (location.state?.from) {
|
||||
navigate(-1);
|
||||
} else {
|
||||
navigate('/projects');
|
||||
}
|
||||
};
|
||||
// Register ESC keyboard shortcut
|
||||
useKeyExit(handleBack, { scope: Scope.SETTINGS });
|
||||
|
||||
Reference in New Issue
Block a user