Carousel cleanup leaves reInit listener attached
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.
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.)
I've resolved this on my fork:
- Branch:
fix/carousel-missing-reinit-cleanup - Commit:
5c78659
Added api?.off("reInit", onSelect) inside the useEffect cleanup function in carousel.tsx.