Skip to content

Commit

Permalink
Fix search scroll reset
Browse files Browse the repository at this point in the history
  • Loading branch information
js0mmer committed Jun 1, 2023
1 parent cedc558 commit 5e1d961
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions site/src/component/SearchHitContainer/SearchHitContainer.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState, useEffect, Component, FC } from 'react';
import React, { useState, useEffect, Component, FC, useRef } from 'react';
import './SearchHitContainer.scss';

import { useAppSelector } from '../../store/hooks';
Expand All @@ -14,11 +14,11 @@ interface SearchHitContainerProps {
const SearchHitContainer: FC<SearchHitContainerProps> = ({ index, CourseHitItem, ProfessorHitItem }) => {
const courseResults = useAppSelector(state => state.search.courses.results);
const professorResults = useAppSelector(state => state.search.professors.results);
const containerDivRef = React.createRef<HTMLDivElement>();
const containerDivRef = useRef<HTMLDivElement>(null);

useEffect(() => {
containerDivRef.current!.scrollTop = 0;
});
}, [courseResults, professorResults]);

if (index == 'professors' && !ProfessorHitItem) {
throw 'Professor Component not provided';
Expand Down

0 comments on commit 5e1d961

Please sign in to comment.