Skip to content

Commit

Permalink
Merge pull request #1286 from nextstrain/fix/web-dataset-search
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan-aksamentov authored Oct 20, 2023
2 parents c3a4e7e + dc2b007 commit e14b9f6
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { get, isNil, sortBy } from 'lodash'
import { lighten } from 'polished'
import React, { forwardRef, useCallback, useEffect, useMemo, useRef } from 'react'
import { ListGroup } from 'reactstrap'
import { useRecoilState, useRecoilValue } from 'recoil'
import { ListGenericCss } from 'src/components/Common/List'
import { DatasetInfo } from 'src/components/Main/DatasetInfo'
Expand Down Expand Up @@ -95,6 +94,9 @@ export function DatasetSelectorList({
}
}, [autodetectRunState, autodetectResult.itemsInclude, onDatasetHighlighted, setAutodetectRunState])

const ulRef = useRef<HTMLUListElement>(null)
useEffect(() => ulRef.current?.scrollTo({ top: 0, left: 0, behavior: 'smooth' }), [searchTerm])

const listItems = useMemo(() => {
return (
<>
Expand Down Expand Up @@ -126,7 +128,7 @@ export function DatasetSelectorList({
)
}, [datasetHighlighted, itemsInclude, itemsNotInclude, itemsStartWith, onItemClick])

return <Ul>{listItems}</Ul>
return <Ul ref={ulRef}>{listItems}</Ul>
}

function nodeRefSetOrDelete<T extends HTMLElement>(map: Map<string, T>, key: string) {
Expand All @@ -139,7 +141,7 @@ function nodeRefSetOrDelete<T extends HTMLElement>(map: Map<string, T>, key: str
}
}

export const Ul = styled(ListGroup)`
export const Ul = styled.ul`
${ListGenericCss};
flex: 1;
overflow: auto;
Expand Down

1 comment on commit e14b9f6

@vercel
Copy link

@vercel vercel bot commented on e14b9f6 Oct 20, 2023

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

nextclade – ./

nextclade-nextstrain.vercel.app
nextclade.vercel.app
nextclade-git-master-nextstrain.vercel.app

Please sign in to comment.