Revert "opt: auto-scroll behavior to reactivate only on user scroll"

This reverts commit 848f6277cb56a0829e7f1da61f2f3ab21ae1064c.
This commit is contained in:
Memory 2025-10-28 13:35:21 +08:00 committed by GitHub
parent 0b2f64f42d
commit 98be9d3065
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -44,7 +44,6 @@ const Logs: React.FC = () => {
return localStorage.getItem(LOGS_FILTER_KEY) || ''
})
const [trace, setTrace] = useState(true)
const containerRef = useRef<HTMLDivElement>(null)
const virtuosoRef = useRef<VirtuosoHandle>(null)
const filteredLogs = useMemo(() => {
@ -58,22 +57,6 @@ const Logs: React.FC = () => {
localStorage.setItem(LOGS_FILTER_KEY, filter)
}, [filter])
useEffect((): void | (() => void) => {
if (!trace) {
const container = containerRef.current
if (container) {
const handleScroll = () => {
setTrace(true)
container.removeEventListener('wheel', handleScroll)
}
container.addEventListener('wheel', handleScroll)
return () => {
container.removeEventListener('wheel', handleScroll)
}
}
}
}, [trace])
useEffect(() => {
if (!trace) return
virtuosoRef.current?.scrollToIndex({
@ -113,9 +96,7 @@ const Logs: React.FC = () => {
variant={trace ? 'solid' : 'bordered'}
title={t('logs.autoScroll')}
onPress={() => {
if (trace) {
setTrace(false)
}
setTrace((prev) => !prev)
}}
>
<IoLocationSharp className="text-lg" />
@ -136,7 +117,7 @@ const Logs: React.FC = () => {
</div>
<Divider />
</div>
<div className="h-[calc(100vh-100px)] mt-px" ref={containerRef}>
<div className="h-[calc(100vh-100px)] mt-px">
<Virtuoso
ref={virtuosoRef}
data={filteredLogs}