Skip to content

Commit ee22d1f

Browse files
committed
Fix loading steps from the search params
1 parent 7d08db8 commit ee22d1f

1 file changed

Lines changed: 19 additions & 3 deletions

File tree

src/components/tutorial/TutorialWindow.tsx

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,7 @@ export function TutorialWindow({
486486
const [isClosed, setIsClosed] = useState(tutorialData.isClosed);
487487

488488
const { article: activeArticleFromSearch } = useSearch({ strict: false });
489+
const navigate = useNavigate();
489490

490491
const [activeStep, setActiveStep] = useState(
491492
tutorialData.tutorialStep || articles[0].title,
@@ -498,13 +499,28 @@ export function TutorialWindow({
498499
) {
499500
const articleInSearch = decodeURIComponent(
500501
activeArticleFromSearch.toLowerCase(),
502+
).trim();
503+
504+
console.info({
505+
articleInSearch,
506+
});
507+
508+
const article = articles.find(
509+
(a) => a.title.toLowerCase().trim() === articleInSearch,
501510
);
502511

503-
if (articles.find((a) => a.title === articleInSearch)) {
504-
setActiveStep(articleInSearch);
512+
if (article) {
513+
setActiveStep(article.title);
514+
navigate({
515+
to: ".",
516+
search: ({ article: _, ...old }) => {
517+
return { ...old };
518+
},
519+
replace: true,
520+
});
505521
}
506522
}
507-
}, [activeArticleFromSearch]);
523+
}, [activeArticleFromSearch, navigate]);
508524

509525
const router = useRouter();
510526

0 commit comments

Comments
 (0)