RocketChat / RocketChat/Rocket.Chat.ReactNative

fix: replace module-scoped ref registry with instance-local ref in UIKit Overflow component

Open
#7,095 3 comments 0 reactions 1 assignee View on GitHub

@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 blockId seen during the app session accumulates in memory.
  • Wrong anchor: when blockId is empty (falls back to ''>) or repeats across different component instances, multiple Overflow components share the same ref, causing the Popover to 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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.