chore: peroid not auto scroll

pull/22133/head
Joel 10 months ago
parent fd7396d8f9
commit 1e0426ca6f

@ -4,18 +4,21 @@ import cn from '@/utils/classnames'
type OptionListItemProps = { type OptionListItemProps = {
isSelected: boolean isSelected: boolean
onClick: () => void onClick: () => void
noAutoScroll?: boolean
} & React.LiHTMLAttributes<HTMLLIElement> } & React.LiHTMLAttributes<HTMLLIElement>
const OptionListItem: FC<OptionListItemProps> = ({ const OptionListItem: FC<OptionListItemProps> = ({
isSelected, isSelected,
onClick, onClick,
noAutoScroll,
children, children,
}) => { }) => {
const listItemRef = useRef<HTMLLIElement>(null) const listItemRef = useRef<HTMLLIElement>(null)
useEffect(() => { useEffect(() => {
if (isSelected) if (isSelected && !noAutoScroll)
listItemRef.current?.scrollIntoView({ behavior: 'instant' }) listItemRef.current?.scrollIntoView({ behavior: 'instant' })
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []) }, [])
return ( return (

@ -58,6 +58,7 @@ const Options: FC<TimeOptionsProps> = ({
key={period} key={period}
isSelected={isSelected} isSelected={isSelected}
onClick={handleSelectPeriod.bind(null, period)} 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} {period}
</OptionListItem> </OptionListItem>

Loading…
Cancel
Save