Skip to content

refactor: replace ReactElement type annotations with ReactNode in components#40816

Merged
ggazzo merged 1 commit into
developfrom
refactor/prepare-types-for-react-19-14
Jun 9, 2026
Merged

refactor: replace ReactElement type annotations with ReactNode in components#40816
ggazzo merged 1 commit into
developfrom
refactor/prepare-types-for-react-19-14

Conversation

@tassoevan

@tassoevan tassoevan commented Jun 4, 2026

Copy link
Copy Markdown
Member

⚠️ This is part 14/23 of #40796. PR for refactor/prepare-types-for-react-19-13 must be merged first.


Proposed changes (including videos or screenshots)

As a first step towards upgrading to React 19, it handles types from @types/react looking forward the next major.

Issue(s)

Task: ARCH-2170

Steps to test or reproduce

Further comments

No runtime change is expected from it.

Summary by CodeRabbit

Release Notes

  • Refactor
    • Improved TypeScript type definitions across UI components for better type flexibility and consistency. Enhanced type support for component properties and hook parameters to accommodate a wider range of valid React elements and references. All changes are internal with no impact on user-facing functionality.

@changeset-bot

changeset-bot Bot commented Jun 4, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: e3fe5d3

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai

coderabbitai Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

This PR systematically updates TypeScript type annotations across navbar search, modal, portal, and sidebar components. It removes explicit ReactElement return type annotations from components, widens prop types from ReactElement to ReactNode, and updates ref types to accept null values, preparing components for React 19 compatibility.

Changes

React Type Annotations Refactor

Layer / File(s) Summary
NavBar Search Component Type Widening
apps/meteor/client/navbar/NavBarSearch/NavBarSearchItem.tsx, apps/meteor/client/navbar/NavBarSearch/NavBarSearchItemWithData.tsx, apps/meteor/client/navbar/NavBarSearch/NavBarSearchRow.tsx, apps/meteor/client/navbar/NavBarSearch/NavBarSearchUserRow.tsx
Navbar search component hierarchy widens avatar, actions, badges, and AvatarTemplate prop types from ReactElement to ReactNode; NavBarSearchRow removes explicit ReactElement return type annotation.
Settings Modal Type Simplification
apps/meteor/client/navbar/NavBarSettingsToolbar/UserMenu/EditStatusModal.tsx, apps/meteor/client/navbar/NavBarSettingsToolbar/UserMenu/KeyboardShortcutsModal.tsx
Explicit ReactElement return type annotations removed from EditStatusModal and KeyboardShortcutsModal components, with type imports updated to reflect actual usage.
Portal Component Type Cleanup
apps/meteor/client/portals/VideoConfPopupPortal.tsx
VideoConfPortal removes explicit ReactElement return type and narrows type imports to ReactNode only.
Sidebar Footer Type Cleanup
apps/meteor/client/sidebar/footer/SidebarFooter.tsx, apps/meteor/client/sidebar/footer/SidebarFooterDefault.tsx, apps/meteor/client/sidebar/footer/SidebarFooterWatermark.tsx
Explicit ReactElement or ReactElement | null return type annotations removed from footer components; type imports updated to match actual usage.
Sidebar Hooks Ref Type Widening
apps/meteor/client/sidebar/hooks/usePreventDefault.ts, apps/meteor/client/sidebar/hooks/useShortcutOpenMenu.ts
Ref parameter types widened from RefObject<Element> to RefObject<Element | null> in sidebar hooks to accommodate refs with null values.
Sidebar Item Template Logic and Types
apps/meteor/client/sidebar/RoomList/SidebarItemTemplateWithData.tsx
Type imports updated to include ReactNode and ComponentType; sidebar toggle click handler refactored from short-circuit expression to explicit if (!selected) sidebar.toggle();; menu ternary function removes explicit ReactElement return type annotation.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • RocketChat/Rocket.Chat#40815: Overlaps with the same refactor of stripping unnecessary ReactElement type annotations from React components.
  • RocketChat/Rocket.Chat#40814: Directly matches the broader refactor removing unnecessary ReactElement annotations from component typings.
  • RocketChat/Rocket.Chat#40813: Updates React typings by removing explicit ReactElement return/type annotations and widening to ReactNode across components, reflecting the same React 19 type-prep pattern.

Suggested labels

type: chore

Suggested reviewers

  • ggazzo
  • dougfabris
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: replacing ReactElement type annotations with ReactNode across multiple components.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

Errors (2)
  • REACT-19: Request failed with status code 401
  • ARCH-2170: Request failed with status code 401

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 and usage tips.

@dionisio-bot

dionisio-bot Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Looks like this PR is ready to merge! 🎉
If you have any trouble, please check the PR guidelines

@codecov

codecov Bot commented Jun 4, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.30769% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 70.14%. Comparing base (6941184) to head (e3fe5d3).
⚠️ Report is 1 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #40816      +/-   ##
===========================================
- Coverage    70.14%   70.14%   -0.01%     
===========================================
  Files         3340     3341       +1     
  Lines       123638   123646       +8     
  Branches     22057    22095      +38     
===========================================
+ Hits         86722    86726       +4     
+ Misses       33573    33568       -5     
- Partials      3343     3352       +9     
Flag Coverage Δ
e2e 59.37% <90.90%> (-0.05%) ⬇️
e2e-api 46.24% <ø> (-0.02%) ⬇️
unit 70.97% <100.00%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@tassoevan tassoevan force-pushed the refactor/prepare-types-for-react-19-14 branch from 5a5f43e to 62436dc Compare June 9, 2026 04:36
@tassoevan tassoevan force-pushed the refactor/prepare-types-for-react-19-14 branch from 62436dc to e3fe5d3 Compare June 9, 2026 05:27
@tassoevan tassoevan added the stat: QA assured Means it has been tested and approved by a company insider label Jun 9, 2026
@tassoevan tassoevan added this to the 8.6.0 milestone Jun 9, 2026
@tassoevan tassoevan requested a review from a team June 9, 2026 05:27
@dionisio-bot dionisio-bot Bot added the stat: ready to merge PR tested and approved waiting for merge label Jun 9, 2026
@tassoevan tassoevan marked this pull request as ready for review June 9, 2026 05:27

@coderabbitai coderabbitai Bot 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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
apps/meteor/client/sidebar/hooks/useShortcutOpenMenu.ts (1)

6-20: ⚠️ Potential issue | 🟠 Major

Guard ref.current before calling tinykeys to prevent mount-time crashes

apps/meteor/client/sidebar/hooks/useShortcutOpenMenu.ts still calls tinykeys(ref.current as HTMLElement, ...) even though the hook accepts RefObject<Element | null>. If ref.current is null, tinykeys will throw when it tries to attach listeners.

Proposed fix
 export const useShortcutOpenMenu = (ref: RefObject<Element | null>): void => {
 	useEffect(() => {
-		const unsubscribe = tinykeys(ref.current as HTMLElement, {
+		const element = ref.current;
+		if (!element) {
+			return;
+		}
+
+		const unsubscribe = tinykeys(element as HTMLElement, {
 			Alt: (event) => {
 				if (!(event.target as HTMLElement).className.includes('rcx-sidebar-item')) {
 					return;
 				}
 				event.preventDefault();
 				(event.target as HTMLElement).querySelector('button')?.click();
 			},
 		});
 		return (): void => {
 			unsubscribe();
 		};
 	}, [ref]);
 };
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/meteor/client/sidebar/hooks/useShortcutOpenMenu.ts` around lines 6 - 20,
The hook useShortcutOpenMenu calls tinykeys on ref.current unguarded; fix by
reading const el = ref.current inside the useEffect and returning early if el is
null so tinykeys is only invoked when an HTMLElement exists, then call
tinykeys(el, ...) and return the unsubscribe from that call (or a no-op if
tinykeys wasn't created) to ensure cleanup is safe when the ref is not yet
mounted.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@apps/meteor/client/sidebar/hooks/useShortcutOpenMenu.ts`:
- Around line 6-20: The hook useShortcutOpenMenu calls tinykeys on ref.current
unguarded; fix by reading const el = ref.current inside the useEffect and
returning early if el is null so tinykeys is only invoked when an HTMLElement
exists, then call tinykeys(el, ...) and return the unsubscribe from that call
(or a no-op if tinykeys wasn't created) to ensure cleanup is safe when the ref
is not yet mounted.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e513d8db-6f10-4817-a161-c5954654c8a1

📥 Commits

Reviewing files that changed from the base of the PR and between 6941184 and e3fe5d3.

📒 Files selected for processing (13)
  • apps/meteor/client/navbar/NavBarSearch/NavBarSearchItem.tsx
  • apps/meteor/client/navbar/NavBarSearch/NavBarSearchItemWithData.tsx
  • apps/meteor/client/navbar/NavBarSearch/NavBarSearchRow.tsx
  • apps/meteor/client/navbar/NavBarSearch/NavBarSearchUserRow.tsx
  • apps/meteor/client/navbar/NavBarSettingsToolbar/UserMenu/EditStatusModal.tsx
  • apps/meteor/client/navbar/NavBarSettingsToolbar/UserMenu/KeyboardShortcutsModal.tsx
  • apps/meteor/client/portals/VideoConfPopupPortal.tsx
  • apps/meteor/client/sidebar/RoomList/SidebarItemTemplateWithData.tsx
  • apps/meteor/client/sidebar/footer/SidebarFooter.tsx
  • apps/meteor/client/sidebar/footer/SidebarFooterDefault.tsx
  • apps/meteor/client/sidebar/footer/SidebarFooterWatermark.tsx
  • apps/meteor/client/sidebar/hooks/usePreventDefault.ts
  • apps/meteor/client/sidebar/hooks/useShortcutOpenMenu.ts
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
  • GitHub Check: 🔎 Code Check / TypeScript
  • GitHub Check: 🔎 Code Check / Code Lint
  • GitHub Check: 🔨 Test Unit / Unit Tests
  • GitHub Check: 🔨 Test Storybook / Test Storybook
  • GitHub Check: 📦 Meteor Build (coverage)
  • GitHub Check: cubic · AI code reviewer
  • GitHub Check: Hacktron Security Check
  • GitHub Check: CodeQL-Build
  • GitHub Check: CodeQL-Build
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx,js}

📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)

**/*.{ts,tsx,js}: Write concise, technical TypeScript/JavaScript with accurate typing in Playwright tests
Avoid code comments in the implementation

Files:

  • apps/meteor/client/sidebar/footer/SidebarFooter.tsx
  • apps/meteor/client/sidebar/hooks/usePreventDefault.ts
  • apps/meteor/client/sidebar/hooks/useShortcutOpenMenu.ts
  • apps/meteor/client/portals/VideoConfPopupPortal.tsx
  • apps/meteor/client/navbar/NavBarSearch/NavBarSearchRow.tsx
  • apps/meteor/client/navbar/NavBarSearch/NavBarSearchUserRow.tsx
  • apps/meteor/client/navbar/NavBarSettingsToolbar/UserMenu/EditStatusModal.tsx
  • apps/meteor/client/navbar/NavBarSearch/NavBarSearchItemWithData.tsx
  • apps/meteor/client/navbar/NavBarSearch/NavBarSearchItem.tsx
  • apps/meteor/client/sidebar/footer/SidebarFooterDefault.tsx
  • apps/meteor/client/sidebar/footer/SidebarFooterWatermark.tsx
  • apps/meteor/client/sidebar/RoomList/SidebarItemTemplateWithData.tsx
  • apps/meteor/client/navbar/NavBarSettingsToolbar/UserMenu/KeyboardShortcutsModal.tsx
🧠 Learnings (6)
📚 Learning: 2026-03-27T14:52:56.865Z
Learnt from: dougfabris
Repo: RocketChat/Rocket.Chat PR: 39892
File: apps/meteor/client/views/room/contextualBar/Threads/Thread.tsx:150-155
Timestamp: 2026-03-27T14:52:56.865Z
Learning: In Rocket.Chat, there are two different `ModalBackdrop` components with different prop APIs. During review, confirm the import source: (1) `rocket.chat/fuselage` `ModalBackdrop` uses `ModalBackdropProps` based on `BoxProps` (so it supports `onClick` and other Box/DOM props) and does not have an `onDismiss` prop; (2) `rocket.chat/ui-client` `ModalBackdrop` uses a narrower props interface like `{ children?: ReactNode; onDismiss?: () => void }` and handles Escape keypress and outside mouse-up, and it does not forward arbitrary DOM props such as `onClick`. Flag mismatched props (e.g., `onDismiss` passed to the fuselage component or `onClick` passed to the ui-client component) and ensure the usage matches the correct component being imported.

Applied to files:

  • apps/meteor/client/sidebar/footer/SidebarFooter.tsx
  • apps/meteor/client/portals/VideoConfPopupPortal.tsx
  • apps/meteor/client/navbar/NavBarSearch/NavBarSearchRow.tsx
  • apps/meteor/client/navbar/NavBarSearch/NavBarSearchUserRow.tsx
  • apps/meteor/client/navbar/NavBarSettingsToolbar/UserMenu/EditStatusModal.tsx
  • apps/meteor/client/navbar/NavBarSearch/NavBarSearchItemWithData.tsx
  • apps/meteor/client/navbar/NavBarSearch/NavBarSearchItem.tsx
  • apps/meteor/client/sidebar/footer/SidebarFooterDefault.tsx
  • apps/meteor/client/sidebar/footer/SidebarFooterWatermark.tsx
  • apps/meteor/client/sidebar/RoomList/SidebarItemTemplateWithData.tsx
  • apps/meteor/client/navbar/NavBarSettingsToolbar/UserMenu/KeyboardShortcutsModal.tsx
📚 Learning: 2026-05-06T12:21:44.083Z
Learnt from: juliajforesti
Repo: RocketChat/Rocket.Chat PR: 40256
File: apps/meteor/client/components/CreateDiscussion/CreateDiscussion.tsx:121-149
Timestamp: 2026-05-06T12:21:44.083Z
Learning: Field wrappers in rocket.chat/fuselage-forms (Field, FieldLabel, FieldRow, FieldError, FieldHint) auto-create htmlFor/id associations, aria-describedby, and role="alert" for errors. Do not manually set htmlFor, id, aria-describedby, or role attributes when using these wrappers. This automatic wiring does not apply to plain rocket.chat/fuselage components, which require explicit ID wiring per the accessibility docs. In code reviews, prefer using fuselage-forms wrappers for form fields and verify there is no unnecessary manual ID/aria wiring in files that use these wrappers. If a component uses plain fuselage components, ensure proper id wiring as per docs.

Applied to files:

  • apps/meteor/client/sidebar/footer/SidebarFooter.tsx
  • apps/meteor/client/sidebar/hooks/usePreventDefault.ts
  • apps/meteor/client/sidebar/hooks/useShortcutOpenMenu.ts
  • apps/meteor/client/portals/VideoConfPopupPortal.tsx
  • apps/meteor/client/navbar/NavBarSearch/NavBarSearchRow.tsx
  • apps/meteor/client/navbar/NavBarSearch/NavBarSearchUserRow.tsx
  • apps/meteor/client/navbar/NavBarSettingsToolbar/UserMenu/EditStatusModal.tsx
  • apps/meteor/client/navbar/NavBarSearch/NavBarSearchItemWithData.tsx
  • apps/meteor/client/navbar/NavBarSearch/NavBarSearchItem.tsx
  • apps/meteor/client/sidebar/footer/SidebarFooterDefault.tsx
  • apps/meteor/client/sidebar/footer/SidebarFooterWatermark.tsx
  • apps/meteor/client/sidebar/RoomList/SidebarItemTemplateWithData.tsx
  • apps/meteor/client/navbar/NavBarSettingsToolbar/UserMenu/KeyboardShortcutsModal.tsx
📚 Learning: 2026-02-10T16:32:42.586Z
Learnt from: tassoevan
Repo: RocketChat/Rocket.Chat PR: 38528
File: apps/meteor/client/startup/roles.ts:14-14
Timestamp: 2026-02-10T16:32:42.586Z
Learning: In Rocket.Chat's Meteor client code, DDP streams use EJSON and Date fields arrive as Date objects; do not manually construct new Date() in stream handlers (for example, in sdk.stream()). Only REST API responses return plain JSON where dates are strings, so implement explicit conversion there if needed. Apply this guidance to all TypeScript files under apps/meteor/client to ensure consistent date handling in DDP streams and REST responses.

Applied to files:

  • apps/meteor/client/sidebar/hooks/usePreventDefault.ts
  • apps/meteor/client/sidebar/hooks/useShortcutOpenMenu.ts
📚 Learning: 2026-05-11T20:30:35.265Z
Learnt from: tassoevan
Repo: RocketChat/Rocket.Chat PR: 40480
File: apps/meteor/client/meteor/startup/accounts.ts:59-61
Timestamp: 2026-05-11T20:30:35.265Z
Learning: In Rocket.Chat’s Meteor client code, when calling `dispatchToastMessage` with `{ type: 'error' }`, pass the raw caught error object as `message` without manual normalization. `dispatchToastMessage` is designed to accept `message: unknown` for error toasts, so avoid converting errors to strings (e.g., `String(error)`) or extracting `error.message` before passing them.

Applied to files:

  • apps/meteor/client/sidebar/hooks/usePreventDefault.ts
  • apps/meteor/client/sidebar/hooks/useShortcutOpenMenu.ts
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In the Rocket.Chat repository, do not reference Biome lint rules in code review feedback. Biome is not used even if biome.json exists; only reference Biome rules if there is explicit, project-wide usage documented. For TypeScript files, review lint implications without Biome guidance unless the project enables Biome rules.

Applied to files:

  • apps/meteor/client/sidebar/hooks/usePreventDefault.ts
  • apps/meteor/client/sidebar/hooks/useShortcutOpenMenu.ts
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In this repository (RocketChat/Rocket.Chat), Biome lint rules are not used even if a biome.json exists. When reviewing TypeScript files (e.g., packages/ui-voip/src/providers/useMediaSession.ts), ensure lint suggestions do not reference Biome-specific rules. Rely on general ESLint/TypeScript lint rules and project conventions instead.

Applied to files:

  • apps/meteor/client/sidebar/hooks/usePreventDefault.ts
  • apps/meteor/client/sidebar/hooks/useShortcutOpenMenu.ts
🔇 Additional comments (12)
apps/meteor/client/navbar/NavBarSettingsToolbar/UserMenu/EditStatusModal.tsx (1)

23-23: LGTM!

Also applies to: 35-35

apps/meteor/client/navbar/NavBarSettingsToolbar/UserMenu/KeyboardShortcutsModal.tsx (1)

89-89: LGTM!

apps/meteor/client/navbar/NavBarSearch/NavBarSearchItem.tsx (1)

2-2: LGTM!

Also applies to: 6-6, 8-8, 12-12

apps/meteor/client/navbar/NavBarSearch/NavBarSearchItemWithData.tsx (1)

3-3: LGTM!

Also applies to: 15-15

apps/meteor/client/navbar/NavBarSearch/NavBarSearchUserRow.tsx (1)

4-4: LGTM!

Also applies to: 14-14

apps/meteor/client/navbar/NavBarSearch/NavBarSearchRow.tsx (1)

13-13: LGTM!

apps/meteor/client/portals/VideoConfPopupPortal.tsx (1)

2-2: LGTM!

Also applies to: 11-11

apps/meteor/client/sidebar/footer/SidebarFooter.tsx (1)

3-5: LGTM!

apps/meteor/client/sidebar/footer/SidebarFooterDefault.tsx (1)

9-41: LGTM!

apps/meteor/client/sidebar/footer/SidebarFooterWatermark.tsx (1)

7-40: LGTM!

apps/meteor/client/sidebar/hooks/usePreventDefault.ts (1)

4-21: LGTM!

apps/meteor/client/sidebar/RoomList/SidebarItemTemplateWithData.tsx (1)

6-7: LGTM!

Also applies to: 114-115, 127-140

@cubic-dev-ai cubic-dev-ai Bot 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.

No issues found across 13 files

Re-trigger cubic

@tassoevan tassoevan enabled auto-merge June 9, 2026 05:42
@ggazzo ggazzo disabled auto-merge June 9, 2026 05:53
@ggazzo ggazzo merged commit 4588c28 into develop Jun 9, 2026
46 checks passed
@ggazzo ggazzo deleted the refactor/prepare-types-for-react-19-14 branch June 9, 2026 05:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stat: QA assured Means it has been tested and approved by a company insider stat: ready to merge PR tested and approved waiting for merge type: chore

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants