diff --git a/src/frontend/src/components/buttons/SpotlightButton.tsx b/src/frontend/src/components/buttons/SpotlightButton.tsx index c524e0b947..a9bc336482 100644 --- a/src/frontend/src/components/buttons/SpotlightButton.tsx +++ b/src/frontend/src/components/buttons/SpotlightButton.tsx @@ -1,14 +1,15 @@ import { t } from '@lingui/macro'; import { ActionIcon } from '@mantine/core'; -import { spotlight } from '@mantine/spotlight'; import { IconCommand } from '@tabler/icons-react'; +import { firstSpotlight } from '../nav/Layout'; + /** * A button which opens the quick command modal */ export function SpotlightButton() { return ( - spotlight.open()} title={t`Open spotlight`}> + firstSpotlight.open()} title={t`Open spotlight`}> ); diff --git a/src/frontend/src/components/nav/Layout.tsx b/src/frontend/src/components/nav/Layout.tsx index 0e2c6c233c..96827dcf14 100644 --- a/src/frontend/src/components/nav/Layout.tsx +++ b/src/frontend/src/components/nav/Layout.tsx @@ -1,8 +1,7 @@ import { t } from '@lingui/macro'; import { Container, Flex, Space } from '@mantine/core'; -import { Spotlight } from '@mantine/spotlight'; +import { Spotlight, createSpotlight } from '@mantine/spotlight'; import { IconSearch } from '@tabler/icons-react'; -import { useEffect, useState } from 'react'; import { Navigate, Outlet, useLocation, useNavigate } from 'react-router-dom'; import { getActions } from '../../defaults/actions'; @@ -25,24 +24,11 @@ export const ProtectedRoute = ({ children }: { children: JSX.Element }) => { return children; }; +export const [firstStore, firstSpotlight] = createSpotlight(); + export default function LayoutComponent() { const navigate = useNavigate(); - const location = useLocation(); - const defaultactions = getActions(navigate); - const [actions, setActions] = useState(defaultactions); - const [customActions, setCustomActions] = useState(false); - - function actionsAreChanging(change: []) { - if (change.length > defaultactions.length) setCustomActions(true); - setActions(change); - } - useEffect(() => { - if (customActions) { - setActions(defaultactions); - setCustomActions(false); - } - }, [location]); return ( @@ -54,10 +40,14 @@ export default function LayoutComponent() {