Skip to content

Commit

Permalink
fix: scroll to top on search page when cocktail gets selected (#363)
Browse files Browse the repository at this point in the history
Signed-off-by: Johannes Groß <mail@gross-johannes.de>
  • Loading branch information
jo-gross authored Aug 10, 2024
1 parent 3d67066 commit a883568
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pages/workspaces/[workspaceId]/search.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { useState } from 'react';
import { useEffect, useState } from 'react';
import { CocktailRecipeFull } from '../../../models/CocktailRecipeFull';
import CocktailRecipeCardItem from '../../../components/cocktails/CocktailRecipeCardItem';
import { SearchModal } from '../../../components/modals/SearchModal';
import { useRouter } from 'next/router';

interface SearchPageProps {
showImage?: boolean;
Expand All @@ -12,6 +13,12 @@ interface SearchPageProps {
export default function SearchPage(props: SearchPageProps) {
const [selectedCocktail, setSelectedCocktail] = useState<CocktailRecipeFull | undefined>(undefined);

const router = useRouter();

useEffect(() => {
window.scrollTo({ top: 0, behavior: 'smooth' });
}, [selectedCocktail]);

return (
<div className={'flex flex-col-reverse gap-2 md:flex-row'}>
<div className={'card w-full flex-1'}>
Expand Down

0 comments on commit a883568

Please sign in to comment.