@@ -765,6 +765,8 @@ const HackathonListContainer = styled.div`
765765 justify-content: center;
766766 gap: 0.5rem; /* Decreased gap */
767767 padding: 1rem;
768+ max-height: 80vh;
769+ overflow-y: auto;
768770
769771 @media (min-width: 768px) {
770772 justify-content: space-around;
@@ -822,6 +824,7 @@ const HackathonList = () => {
822824 const [ domainFilter , setDomainFilter ] = useState ( '' ) ;
823825 const [ highlightId , setHighlightId ] = useState ( null ) ;
824826 const cardRefs = useRef ( { } ) ;
827+ const containerRef = useRef ( null ) ;
825828
826829 // Filter logic
827830 const filteredHackathons = hackathons . filter ( ( hackathon ) => {
@@ -856,13 +859,21 @@ const HackathonList = () => {
856859 } , [ locationFilter , monthFilter , domainFilter ] ) ;
857860
858861 useEffect ( ( ) => {
859- if ( highlightId && cardRefs . current [ highlightId ] ) {
860- const el = cardRefs . current [ highlightId ] ;
861- el . scrollIntoView ( { behavior : 'smooth' , block : 'center' } ) ;
862- el . style . boxShadow = '0 0 0 4px #00a6fb, 0 0 20px #00a6fb' ;
863- el . style . transition = 'box-shadow 0.5s' ;
862+ if ( highlightId && cardRefs . current [ highlightId ] && containerRef . current ) {
863+ const card = cardRefs . current [ highlightId ] ;
864+ const container = containerRef . current ;
865+ // Scroll so the card is centered in the container
866+ const cardTop = card . offsetTop ;
867+ const cardHeight = card . offsetHeight ;
868+ const containerHeight = container . offsetHeight ;
869+ container . scrollTo ( {
870+ top : cardTop - containerHeight / 2 + cardHeight / 2 ,
871+ behavior : 'smooth' ,
872+ } ) ;
873+ card . style . boxShadow = '0 0 0 4px #00a6fb, 0 0 20px #00a6fb' ;
874+ card . style . transition = 'box-shadow 0.5s' ;
864875 setTimeout ( ( ) => {
865- el . style . boxShadow = '' ;
876+ card . style . boxShadow = '' ;
866877 } , 2000 ) ;
867878 }
868879 } , [ highlightId , displayHackathons . length ] ) ;
@@ -898,7 +909,7 @@ const HackathonList = () => {
898909 onChange = { ( e ) => setDomainFilter ( e . target . value ) }
899910 />
900911 </ FilterContainer >
901- < HackathonListContainer >
912+ < HackathonListContainer ref = { containerRef } >
902913 { displayHackathons . map ( ( hackathon ) => (
903914 < HackathonCardComponent
904915 key = { hackathon . shareLink }
0 commit comments