fix: replace module-scoped ref registry with instance-local ref in UIKit Overflow#7123
fix: replace module-scoped ref registry with instance-local ref in UIKit Overflow#7123deepak0x wants to merge 1 commit intoRocketChat:developfrom
Conversation
…Kit Overflow Refs were stored in a module-level map keyed by blockId, which caused two problems: - Memory leak: refs were never cleaned up, so every blockId seen during the app session accumulated in the map for the lifetime of the process. - Wrong popover anchor: when blockId was empty or shared across instances, multiple Overflow components ended up sharing the same ref, causing the Popover to anchor to the wrong element. Switched to a useRef inside the component so the ref lifecycle is tied to the instance. Closes RocketChat#7095
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📜 Recent review details🧰 Additional context used📓 Path-based instructions (5)**/*.{js,jsx,ts,tsx,json}📄 CodeRabbit inference engine (CLAUDE.md)
Files:
**/*.{js,jsx,ts,tsx}📄 CodeRabbit inference engine (CLAUDE.md)
Files:
**/*.{ts,tsx}📄 CodeRabbit inference engine (CLAUDE.md)
Files:
app/containers/**/*.{ts,tsx}📄 CodeRabbit inference engine (CLAUDE.md)
Files:
**/*.{js,ts,jsx,tsx}📄 CodeRabbit inference engine (AGENTS.md)
Files:
🧠 Learnings (2)📚 Learning: 2026-04-07T17:49:17.538ZApplied to files:
📚 Learning: 2026-04-07T17:49:17.538ZApplied to files:
🔇 Additional comments (2)
WalkthroughThe Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Suggested labels
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
The
Overflowcomponent was storing refs in a module-scopedtouchablemap keyed byblockId. Two issues with that:blockIdever rendered stayed in memory until the app shut down.blockIdwas missing or repeated across instances, multipleOverflowcomponents ended up sharing the same ref, so thePopoverwould sometimes anchor to the wrong button.Switched to an instance-local
useRefso the ref's lifecycle is tied to the component. I kept theas React.RefObject<any>cast that was already in the original code, sinceTouch's ref is aRectButtoninstance andPopover.fromstrictly wants aRefObject<View>. Same workaround, just no longer global.Issue(s)
Closes #7095
How to test or reproduce
The bug shows up when multiple
Overflowcomponents are rendered on the same screen (e.g. UIKit messages with more than one overflow menu, or when anOverflowis re-rendered with an emptyblockId). Tapping the kebab on one would sometimes pop the menu over a different button. With this fix each instance has its own ref, so the popover always anchors correctly.Types of changes
Checklist
Summary by CodeRabbit