OpenCut icon indicating copy to clipboard operation
OpenCut copied to clipboard

Carousel cleanup leaves reInit listener attached

Open pidouga-dev opened this issue 5 months ago • 2 comments

Summary

The Carousel component subscribes the same onSelect handler to both Embla reInit and select events, but the effect cleanup only removes the select listener.

That means the reInit listener can remain attached after the effect is cleaned up, which can lead to duplicate handlers after remounts or API changes.

I prepared a minimal patch in a public fork: https://github.com/pidouga-dev/OpenCut/tree/codex/carousel-reinit-cleanup

Commit: https://github.com/pidouga-dev/OpenCut/commit/9506272ac9f4025d4f3aff0ff5a6542cc5752ea0

Patch

Add the missing api.off("reInit", onSelect) call in the cleanup function.

Verification

  • bun --filter @opencut/web build

Note: I could not open a PR because GitHub shows that this repository limits pull request creation to collaborators.

pidouga-dev avatar Jun 05 '26 23:06 pidouga-dev

This is the same bug as #821 — I've posted a fix there: https://github.com/seuthootDev/OpenCut/tree/fix/carousel-reinit-listener-leak

(One-line addition: api?.off("reInit", onSelect) in the cleanup of the effect in apps/web/src/components/ui/carousel.tsx.)

seuthootDev avatar Aug 22 '26 10:08 seuthootDev

I've resolved this on my fork:

Added api?.off("reInit", onSelect) inside the useEffect cleanup function in carousel.tsx.

killer1panda avatar Sep 08 '26 08:09 killer1panda