Skip to content

Commit

Permalink
#75 added scroll to top at searching.
Browse files Browse the repository at this point in the history
  • Loading branch information
artzub committed Jan 5, 2021
1 parent c5ed475 commit 952fcd9
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/components/Header/components/UserStep/Body.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ const Body = () => {
const dispatch = useDispatch();
const redirectTo = useRedirectTo(UrlPratTypes.profile);
const inputRef = useRef();
const listRef = useRef();
const [search, setSearch] = useState('');
const [neverChange, setNeverChange] = useState(true);
const { isFetching, items, top } = useSelector(slice.selectors.getState);
Expand All @@ -77,6 +78,9 @@ const Body = () => {
(event) => {
setNeverChange(false);
setSearch(event.target.value);
if (listRef.current) {
listRef.current.scrollIntoViewIfNeeded();
}
},
[],
);
Expand Down Expand Up @@ -125,6 +129,7 @@ const Body = () => {
<ListContainer>
{!neverChange && (
<List
ref={listRef}
dense
subheader={SearchHeader}
>
Expand Down

0 comments on commit 952fcd9

Please sign in to comment.