From 0b2b10a4cd122d5ec20cf99822177b9befd51d10 Mon Sep 17 00:00:00 2001 From: Heising Date: Tue, 31 Oct 2023 17:10:41 +0800 Subject: [PATCH] fix(date-picker): fix date-picker scroll the bottom jump scrollTop the bug --- src/popup/Popup.tsx | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/popup/Popup.tsx b/src/popup/Popup.tsx index 517d624498..95caab9095 100644 --- a/src/popup/Popup.tsx +++ b/src/popup/Popup.tsx @@ -8,7 +8,6 @@ import { Placement } from '@popperjs/core'; import useControlled from '../hooks/useControlled'; import useAnimation from '../_util/useAnimation'; import useConfig from '../hooks/useConfig'; -import usePrevious from '../hooks/usePrevious'; import { TdPopupProps } from './type'; import Portal from '../common/Portal'; import useTrigger from './hooks/useTrigger'; @@ -66,7 +65,6 @@ const Popup = forwardRef((originalProps, ref) => { const { keepExpand, keepFade } = useAnimation(); const { height: windowHeight, width: windowWidth } = useWindowSize(); const [visible, onVisibleChange] = useControlled(props, 'visible', props.onVisibleChange); - const prevVisible = usePrevious(visible); const [popupElement, setPopupElement] = useState(null); const triggerRef = useRef(null); // 记录 trigger 元素 @@ -124,10 +122,10 @@ const Popup = forwardRef((originalProps, ref) => { // 下拉展开时更新内部滚动条 useEffect(() => { if (!triggerRef.current) triggerRef.current = getTriggerDom(); - if (prevVisible !== visible && visible) { + if (visible) { updateScrollTop?.(contentRef.current); } - }, [visible, prevVisible, updateScrollTop, getTriggerDom]); + }, [visible, updateScrollTop, getTriggerDom]); function handleExited() { !destroyOnClose && popupElement && (popupElement.style.display = 'none');