Skip to content

Commit

Permalink
fix: Always center flows on load (#3953)
Browse files Browse the repository at this point in the history
  • Loading branch information
DafyddLlyr authored Nov 15, 2024
1 parent b50e975 commit b92d401
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useEffect, useRef } from "react";
import { Link } from "react-navi";
import { Link, useLoadingRoute } from "react-navi";
import scrollIntoView from "scroll-into-view-if-needed";

import { rootFlowPath } from "../../../../../routes/utils";
Expand All @@ -14,24 +14,29 @@ const EndPoint: React.FC<{ text: string }> = ({ text }) => {

const href = rootFlowPath(false);

const currentPath = rootFlowPath(true);
const isLoading = useLoadingRoute();

useEffect(() => {
if (isStart && el.current) {
if (isLoading) return;

scrollIntoView(
el.current,
flowLayout === FlowLayout.TOP_DOWN
? {
scrollMode: "if-needed",
scrollMode: "always",
block: "nearest",
inline: "center",
}
: {
scrollMode: "if-needed",
scrollMode: "always",
block: "center",
inline: "nearest",
},
);
}
}, [flowLayout, isStart]);
}, [flowLayout, isStart, currentPath, isLoading]);

return (
<li
Expand Down

0 comments on commit b92d401

Please sign in to comment.