Fixed id scrolling when clicking from Store
This commit is contained in:
parent
cad4c508a9
commit
98e40f25e6
3 changed files with 36 additions and 31 deletions
|
|
@ -41,12 +41,23 @@ import {
|
||||||
} from "../../../../types/components";
|
} from "../../../../types/components";
|
||||||
import { gradients } from "../../../../utils/styleUtils";
|
import { gradients } from "../../../../utils/styleUtils";
|
||||||
import { useStoreStore } from "../../../../stores/storeStore";
|
import { useStoreStore } from "../../../../stores/storeStore";
|
||||||
|
import { useParams } from "react-router-dom";
|
||||||
|
|
||||||
export default function GeneralPage() {
|
export default function GeneralPage() {
|
||||||
const setCurrentFlowId = useFlowsManagerStore(
|
const setCurrentFlowId = useFlowsManagerStore(
|
||||||
(state) => state.setCurrentFlowId,
|
(state) => state.setCurrentFlowId,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const { scrollId } = useParams();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const element = document.getElementById(scrollId ?? "null");
|
||||||
|
if (element) {
|
||||||
|
// 👇 Will scroll smoothly to the top of the next section
|
||||||
|
element.scrollIntoView({ behavior: "smooth" });
|
||||||
|
}
|
||||||
|
}, [scrollId]);
|
||||||
|
|
||||||
const [inputState, setInputState] = useState<patchUserInputStateType>(
|
const [inputState, setInputState] = useState<patchUserInputStateType>(
|
||||||
CONTROL_PATCH_USER_STATE,
|
CONTROL_PATCH_USER_STATE,
|
||||||
);
|
);
|
||||||
|
|
@ -272,9 +283,9 @@ export default function GeneralPage() {
|
||||||
handleSaveKey();
|
handleSaveKey();
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Card x-chunk="dashboard-04-chunk-2">
|
<Card x-chunk="dashboard-04-chunk-2" id="api">
|
||||||
<CardHeader>
|
<CardHeader>
|
||||||
<CardTitle>API Key</CardTitle>
|
<CardTitle>Store API Key</CardTitle>
|
||||||
<CardDescription>
|
<CardDescription>
|
||||||
{(hasApiKey && !validApiKey
|
{(hasApiKey && !validApiKey
|
||||||
? INVALID_API_KEY
|
? INVALID_API_KEY
|
||||||
|
|
|
||||||
|
|
@ -180,9 +180,6 @@ export default function StorePage(): JSX.Element {
|
||||||
title={STORE_TITLE}
|
title={STORE_TITLE}
|
||||||
description={STORE_DESC}
|
description={STORE_DESC}
|
||||||
button={
|
button={
|
||||||
<>
|
|
||||||
{StoreApiKeyModal && (
|
|
||||||
<StoreApiKeyModal disabled={loading}>
|
|
||||||
<Button
|
<Button
|
||||||
data-testid="api-key-button-store"
|
data-testid="api-key-button-store"
|
||||||
disabled={loading}
|
disabled={loading}
|
||||||
|
|
@ -191,13 +188,13 @@ export default function StorePage(): JSX.Element {
|
||||||
loading ? "cursor-not-allowed" : "",
|
loading ? "cursor-not-allowed" : "",
|
||||||
)}
|
)}
|
||||||
variant="primary"
|
variant="primary"
|
||||||
|
onClick={() => {
|
||||||
|
navigate("/settings/general/api");
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<IconComponent name="Key" className="mr-2 w-4" />
|
<IconComponent name="Key" className="mr-2 w-4" />
|
||||||
API Key
|
API Key
|
||||||
</Button>
|
</Button>
|
||||||
</StoreApiKeyModal>
|
|
||||||
)}
|
|
||||||
</>
|
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<div className="flex h-full w-full flex-col justify-between">
|
<div className="flex h-full w-full flex-col justify-between">
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ const Router = () => {
|
||||||
>
|
>
|
||||||
<Route index element={<Navigate replace to={"general"} />} />
|
<Route index element={<Navigate replace to={"general"} />} />
|
||||||
<Route path="global-variables" element={<GlobalVariablesPage />} />
|
<Route path="global-variables" element={<GlobalVariablesPage />} />
|
||||||
<Route path="general" element={<GeneralPage />} />
|
<Route path="general/:scrollId?" element={<GeneralPage />} />
|
||||||
<Route path="shortcuts" element={<ShortcutsPage />} />
|
<Route path="shortcuts" element={<ShortcutsPage />} />
|
||||||
</Route>
|
</Route>
|
||||||
<Route
|
<Route
|
||||||
|
|
@ -80,8 +80,6 @@ const Router = () => {
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<Route path="/playground/:id/">
|
<Route path="/playground/:id/">
|
||||||
element=
|
|
||||||
{
|
|
||||||
<Route
|
<Route
|
||||||
path=""
|
path=""
|
||||||
element={
|
element={
|
||||||
|
|
@ -90,7 +88,6 @@ const Router = () => {
|
||||||
</ProtectedRoute>
|
</ProtectedRoute>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
}
|
|
||||||
</Route>
|
</Route>
|
||||||
<Route path="/flow/:id/">
|
<Route path="/flow/:id/">
|
||||||
<Route
|
<Route
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue