mirror of https://github.com/langgenius/dify.git
chore: peroid not auto scroll
This commit is contained in:
parent
fd7396d8f9
commit
1e0426ca6f
|
|
@ -4,18 +4,21 @@ import cn from '@/utils/classnames'
|
|||
type OptionListItemProps = {
|
||||
isSelected: boolean
|
||||
onClick: () => void
|
||||
noAutoScroll?: boolean
|
||||
} & React.LiHTMLAttributes<HTMLLIElement>
|
||||
|
||||
const OptionListItem: FC<OptionListItemProps> = ({
|
||||
isSelected,
|
||||
onClick,
|
||||
noAutoScroll,
|
||||
children,
|
||||
}) => {
|
||||
const listItemRef = useRef<HTMLLIElement>(null)
|
||||
|
||||
useEffect(() => {
|
||||
if (isSelected)
|
||||
if (isSelected && !noAutoScroll)
|
||||
listItemRef.current?.scrollIntoView({ behavior: 'instant' })
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [])
|
||||
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -58,6 +58,7 @@ const Options: FC<TimeOptionsProps> = ({
|
|||
key={period}
|
||||
isSelected={isSelected}
|
||||
onClick={handleSelectPeriod.bind(null, period)}
|
||||
noAutoScroll // if choose PM which would hide(scrolled) AM that may make user confused that there's no am.
|
||||
>
|
||||
{period}
|
||||
</OptionListItem>
|
||||
|
|
|
|||
Loading…
Reference in New Issue