From 388bc59a58a5c486c52cd5e5e75e6530c9ecf1ac Mon Sep 17 00:00:00 2001 From: Neil <4138956+nwparker@users.noreply.github.com> Date: Fri, 29 May 2026 21:57:00 -0700 Subject: [PATCH] fix: cancel popover wheel frames (#3460) --- src/renderer/src/components/ui/popover.tsx | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/renderer/src/components/ui/popover.tsx b/src/renderer/src/components/ui/popover.tsx index 4808917471a..a1df958703a 100644 --- a/src/renderer/src/components/ui/popover.tsx +++ b/src/renderer/src/components/ui/popover.tsx @@ -28,6 +28,18 @@ function PopoverContent({ }: React.ComponentProps & { portalContainer?: HTMLElement | null }) { + const wheelFrameIdsRef = React.useRef>(new Set()) + + React.useEffect( + () => () => { + for (const frameId of wheelFrameIdsRef.current) { + cancelAnimationFrame(frameId) + } + wheelFrameIdsRef.current.clear() + }, + [] + ) + const handleWheel = React.useCallback( (event: React.WheelEvent) => { onWheel?.(event) @@ -55,11 +67,13 @@ function PopoverContent({ if (nextScrollTop !== el.scrollTop) { const previousScrollTop = el.scrollTop event.stopPropagation() - requestAnimationFrame(() => { + const frameId = requestAnimationFrame(() => { + wheelFrameIdsRef.current.delete(frameId) if (el.scrollTop === previousScrollTop) { el.scrollTop = nextScrollTop } }) + wheelFrameIdsRef.current.add(frameId) } }, [onWheel]