Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(date-picker): fix date-picker scroll the bottom jump scrollTop the bug #2573

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/popup/Popup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -66,7 +65,6 @@ const Popup = forwardRef<PopupRef, PopupProps>((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 元素
Expand Down Expand Up @@ -124,10 +122,10 @@ const Popup = forwardRef<PopupRef, PopupProps>((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');
Expand Down
Loading