RocketChat / RocketChat/Rocket.Chat.ReactNative
fix: replace module-scoped ref registry with instance-local ref in UIKit Overflow component
Open
@diegolmello is already working on this.
Since Apr 2, 2026.
🍭 good first issue
- Dominant language
- TypeScript
- Stars
- 2.4k
- Forks
- 1.5k
- Avg merge
- 1d 18h
- Merged PRs (30d)
- 90
Description
Summary
The Overflow component in app/containers/UIKit/Overflow.tsx uses a module-scoped touchable map to store React.RefObject instances keyed by blockId.
Problem
- Ref leaks: refs stored in the module-level map are never removed, so every
blockIdseen during the app session accumulates in memory. - Wrong anchor: when
blockIdis empty (falls back to''>) or repeats across different component instances, multipleOverflowcomponents share the same ref, causing thePopoverto anchor to the wrong element.
Suggested Fix
Replace the global map with an instance-local useRef inside the Overflow component, tying the ref lifecycle to the component instance:
// Before (module-scoped, leaks & collides)
const touchable: { [key: string]: React.RefObject<View | null> } = {};
export const Overflow = ({ element, loading, action, parser }: IOverflow) => {
const blockId = element?.blockId || '';
if (!touchable[blockId]) {
touchable[blockId] = React.createRef();
}
const touchableRef = touchable[blockId] as React.RefObject<any>;
// ...
};
// After (instance-local, safe)
export const Overflow = ({ element, loading, action, parser }: IOverflow) => {
const touchableRef = useRef<React.ElementRef<typeof Touch>>(null);
// ...
};
References
- Flagged in PR #6875: https://github.com/RocketChat/Rocket.Chat.ReactNative/pull/6875#discussion_r2988571189
- Requested by @diegolmello
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.