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]