Skip to content

Commit

Permalink
fix closing and reopening modals
Browse files Browse the repository at this point in the history
  • Loading branch information
hiba9201 committed Dec 10, 2023
1 parent da6a22e commit 4b5a4c2
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion client/components/MainPage/MainPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,22 @@ export function MainPage({ cards, cardsDynamicData, marqueeItems, articles }: Ma

useEffect(() => {
const handlePopState = (e: PopStateEvent) => {
if (e.state.url === '/') {
const slug = e.state.articleSlug;

if (e.state.url === '/' || slug === null) {
setOpenedArticle(null);

return;
}

if (e.state.articleSlug) {
const article = articles.find((a) => a.slug === slug);

if (!article) {
return;
}

setOpenedArticle(article);
}
};

Expand Down

1 comment on commit 4b5a4c2

@ekbdev
Copy link

@ekbdev ekbdev commented on 4b5a4c2 Dec 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deploy preview for transport ready!

✅ Preview
https://transport-66n4e6joy-ekbdev.vercel.app
https://ekbdev-transport-feat-article-modals.vercel.app

Built with commit 4b5a4c2.
This pull request is being automatically deployed with vercel-action

Please sign in to comment.