fix: log viewer auto-follow uses distance-from-bottom instead of element visibility
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1251,11 +1251,14 @@ function LogViewer({ run, adapterType }: { run: HeartbeatRun; adapterType: strin
|
|||||||
}, [initialEvents]);
|
}, [initialEvents]);
|
||||||
|
|
||||||
const updateFollowingState = useCallback(() => {
|
const updateFollowingState = useCallback(() => {
|
||||||
const el = logEndRef.current;
|
const viewportBottom = window.scrollY + window.innerHeight;
|
||||||
if (!el) return;
|
const pageHeight = Math.max(
|
||||||
const rect = el.getBoundingClientRect();
|
document.documentElement.scrollHeight,
|
||||||
const inView = rect.top <= window.innerHeight && rect.bottom >= 0;
|
document.body.scrollHeight,
|
||||||
setIsFollowing((prev) => (prev === inView ? prev : inView));
|
);
|
||||||
|
const distanceFromBottom = pageHeight - viewportBottom;
|
||||||
|
const isNearBottom = distanceFromBottom <= 32;
|
||||||
|
setIsFollowing((prev) => (prev === isNearBottom ? prev : isNearBottom));
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user