From 46a2d04528a5b9bf01565ec0997f49950abda9b1 Mon Sep 17 00:00:00 2001 From: tisonhuang Date: Thu, 5 Mar 2026 12:25:11 +0800 Subject: [PATCH] fix(export): hand off wheel scroll between page and session list --- src/pages/ExportPage.tsx | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/src/pages/ExportPage.tsx b/src/pages/ExportPage.tsx index d44acec..7eab8c2 100644 --- a/src/pages/ExportPage.tsx +++ b/src/pages/ExportPage.tsx @@ -1,4 +1,4 @@ -import { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react' +import { memo, useCallback, useEffect, useMemo, useRef, useState, type WheelEvent } from 'react' import { useLocation } from 'react-router-dom' import { Virtuoso, type VirtuosoHandle } from 'react-virtuoso' import { createPortal } from 'react-dom' @@ -1296,6 +1296,7 @@ function ExportPage() { const contactsLoadTimeoutMsRef = useRef(DEFAULT_CONTACTS_LOAD_TIMEOUT_MS) const contactsAvatarCacheRef = useRef>({}) const contactsVirtuosoRef = useRef(null) + const sessionTableSectionRef = useRef(null) const detailRequestSeqRef = useRef(0) const sessionsRef = useRef([]) const contactsListSizeRef = useRef(0) @@ -3939,6 +3940,23 @@ function ExportPage() { contactsVirtuosoRef.current?.scrollToIndex({ index: 0, align: 'start', behavior: 'smooth' }) window.scrollTo({ top: 0, behavior: 'smooth' }) }, []) + const handleContactsListWheelCapture = useCallback((event: WheelEvent) => { + const deltaY = event.deltaY + if (!deltaY) return + const sectionTop = sessionTableSectionRef.current?.getBoundingClientRect().top ?? 0 + const sectionPinned = sectionTop <= 8 + + if (deltaY > 0 && !sectionPinned) { + event.preventDefault() + window.scrollBy({ top: deltaY, behavior: 'auto' }) + return + } + + if (deltaY < 0 && isContactsListAtTop) { + event.preventDefault() + window.scrollBy({ top: deltaY, behavior: 'auto' }) + } + }, [isContactsListAtTop]) useEffect(() => { if (hasFilteredContacts) return setIsContactsListAtTop(true) @@ -4107,7 +4125,7 @@ function ExportPage() { ]} /> -
+
@@ -4249,7 +4267,10 @@ function ExportPage() { 暂无联系人
) : ( -
+