Skip to content

fix: iOS crash when room back button unread label toggles - #7811

Merged
diegolmello merged 1 commit into
developfrom
fix/bugsnag-error-6aaa1ec5
Oct 19, 2026
Merged

diegolmello merged 1 commit into
developfrom
fix/bugsnag-error-6aaa1ec5

Conversation

@diegolmello

@diegolmello diegolmello commented Oct 16, 2026 •

Copy link
Copy Markdown
Member

Proposed changes

Fixes an iOS crash (NSRangeException: index 3 beyond bounds [0 .. 1]) that happens in RoomView when the back button's unread label toggles. It started in 4.77.0.

LeftButtons passed an undefined label to HeaderBackButton when there were no unreads, where it used to pass ' '. On iOS, @react-navigation/elements renders the label inside RNCMaskedView, a Paper-only view mounted through the Fabric legacy interop. Adding or removing the label flips the masked view's child count between 2 and 4. After absent, present, absent, present, the interop inserts at index 3 into a 2-item list and the app crashes.

LeftButtons now falls back to a blank label, so the child count stays stable. A regression test in LeftButtons.test.tsx covers the toggle.

Issue(s)

https://rocketchat.atlassian.net/browse/NATIVE-1774

How to test or reproduce

  1. On iOS, force the JS room header (iOS below 26 uses it by default)
  2. Open a room
  3. While the room is open, toggle its unread count 0 → 3 → 0 → 3
  4. The app does not crash

Verified:

  • On device, the repro crashed 3 out of 3 times without the fix, and did not crash in 5 runs with it
  • The new Jest test fails without the fix (expected 1, got 3) and passes with it

Screenshots

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • Improvement (non-breaking change which improves a current function)
  • New feature (non-breaking change which adds functionality)
  • Documentation update (if none of the other choices apply)

Checklist

  • I have read the CONTRIBUTING doc
  • I have signed the CLA
  • Lint and unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works (if applicable)
  • I have added necessary documentation (if applicable)
  • Any dependent changes have been merged and published in downstream modules

Further comments

On develop, iOS 26 uses the native header and mostly avoids this path (master-detail threads still reach it). iOS below 26 is still affected.

Summary by CodeRabbit

  • Bug Fixes
    • The room back-button label now remains consistently rendered when there are no unread messages, and displays the unread count when one is present.

@coderabbitai

coderabbitai Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 6644e059-0bcb-48b2-86ed-76aa0d4fced0
📥 Commits

Reviewing files that changed from the base of the PR and between 479ddf9 and 9da57dd.

📒 Files selected for processing: 2
  • app/views/RoomView/components/LeftButtons.tsx
  • app/views/RoomView/components/__tests__/LeftButtons.test.tsx

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

📜 Recent review details
⏰ Context from checks skipped due to timeout: 2
  • GitHub Check: ESLint and Test / run-eslint-and-test
  • GitHub Check: E2E Shard Preflight
🔇 Additional comments: 2
app/views/RoomView/components/LeftButtons.tsx: 1

22-22: LGTM!

Also applies to: 44-44

app/views/RoomView/components/__tests__/LeftButtons.test.tsx: 1

2-4: LGTM!

Also applies to: 10-10, 16-16, 18-18, 20-20, 22-22, 49-51, 56-57, 83-97

Walkthrough

LeftButtons now uses a single-space label when the unread count is absent or zero. A test verifies the label remains mounted as the count changes from null to 3 and then 0.

Changes

Unread label behavior

Layer / File(s) Summary
Default label and count-change test
app/views/RoomView/components/LeftButtons.tsx, app/views/RoomView/components/__tests__/LeftButtons.test.tsx
The back-button label defaults to a single space and displays a formatted count when the count is truthy. The test checks that the label remains mounted as the unread count changes.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Bug fix

Suggested labels: type: bug

Suggested reviewers: rohit3523

Merge Risk: ⚪ Minimal · up to 9da57

The back-button label remains mounted as unread counts change, and the regression test detects the reported child-count failure. No actionable merge risk remains from this change.

Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: fixing an iOS crash caused by toggling the room back button unread label.
Docstring Coverage Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2 files.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Errors were encountered while retrieving linked issues.

Errors: 1
  • JIRA integration encountered authorization issues. Please disconnect and reconnect the integration in the CodeRabbit UI.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown

iOS Build Available

Rocket.Chat 4.78.0.110019

@Rohit3523 Rohit3523 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

The RoomView function-component migration started passing `label={undefined}`
to HeaderBackButton when there are no unreads (it used to pass ' '). On iOS
the label is rendered inside RNCMaskedView, a legacy (Paper) view mounted
through Fabric's legacy interop layer. Its layout-only label wrapper is
flattened, so the label texts are direct children of the masked view: 2
children without a label, 4 with one. When the label appears, disappears and
appears again, the interop layer inserts the last text at index 3 into a
2-element reactSubviews array and throws NSRangeException
"index 3 beyond bounds [0 .. 1]".

Always passing a blank label keeps the masked view's children stable, as
before 4.77.0.
@diegolmello
diegolmello force-pushed the fix/bugsnag-error-6aaa1ec5 branch from 9da57dd to d06d900 Compare October 19, 2026 17:46
@diegolmello
diegolmello merged commit e482582 into develop Oct 19, 2026
1 of 2 checks passed
@diegolmello
diegolmello deleted the fix/bugsnag-error-6aaa1ec5 branch October 19, 2026 17:46

This branch had an error being deployed

3 failed deployments
android_build — d06d9003 Deployed Oct 19, 2026 by diegolmello via Build Android / Hold #7395
ios_build — d06d9003 Deployed Oct 19, 2026 by diegolmello via Build iOS / Hold #7395
approve_e2e_testing — d06d9003 Deployed Oct 19, 2026 by diegolmello via E2E Hold #7395
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants