refactor: replace ReactElement type annotations with ReactNode in components#40816
Conversation
|
WalkthroughThis PR systematically updates TypeScript type annotations across navbar search, modal, portal, and sidebar components. It removes explicit ChangesReact Type Annotations Refactor
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Warning Review ran into problems🔥 ProblemsErrors were encountered while retrieving linked issues. Errors (2)
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 |
|
Looks like this PR is ready to merge! 🎉 |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ 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
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
5a5f43e to
62436dc
Compare
62436dc to
e3fe5d3
Compare
There was a problem hiding this comment.
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 | 🟠 MajorGuard
ref.currentbefore callingtinykeysto prevent mount-time crashes
apps/meteor/client/sidebar/hooks/useShortcutOpenMenu.tsstill callstinykeys(ref.current as HTMLElement, ...)even though the hook acceptsRefObject<Element | null>. Ifref.currentisnull,tinykeyswill 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
📒 Files selected for processing (13)
apps/meteor/client/navbar/NavBarSearch/NavBarSearchItem.tsxapps/meteor/client/navbar/NavBarSearch/NavBarSearchItemWithData.tsxapps/meteor/client/navbar/NavBarSearch/NavBarSearchRow.tsxapps/meteor/client/navbar/NavBarSearch/NavBarSearchUserRow.tsxapps/meteor/client/navbar/NavBarSettingsToolbar/UserMenu/EditStatusModal.tsxapps/meteor/client/navbar/NavBarSettingsToolbar/UserMenu/KeyboardShortcutsModal.tsxapps/meteor/client/portals/VideoConfPopupPortal.tsxapps/meteor/client/sidebar/RoomList/SidebarItemTemplateWithData.tsxapps/meteor/client/sidebar/footer/SidebarFooter.tsxapps/meteor/client/sidebar/footer/SidebarFooterDefault.tsxapps/meteor/client/sidebar/footer/SidebarFooterWatermark.tsxapps/meteor/client/sidebar/hooks/usePreventDefault.tsapps/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.tsxapps/meteor/client/sidebar/hooks/usePreventDefault.tsapps/meteor/client/sidebar/hooks/useShortcutOpenMenu.tsapps/meteor/client/portals/VideoConfPopupPortal.tsxapps/meteor/client/navbar/NavBarSearch/NavBarSearchRow.tsxapps/meteor/client/navbar/NavBarSearch/NavBarSearchUserRow.tsxapps/meteor/client/navbar/NavBarSettingsToolbar/UserMenu/EditStatusModal.tsxapps/meteor/client/navbar/NavBarSearch/NavBarSearchItemWithData.tsxapps/meteor/client/navbar/NavBarSearch/NavBarSearchItem.tsxapps/meteor/client/sidebar/footer/SidebarFooterDefault.tsxapps/meteor/client/sidebar/footer/SidebarFooterWatermark.tsxapps/meteor/client/sidebar/RoomList/SidebarItemTemplateWithData.tsxapps/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.tsxapps/meteor/client/portals/VideoConfPopupPortal.tsxapps/meteor/client/navbar/NavBarSearch/NavBarSearchRow.tsxapps/meteor/client/navbar/NavBarSearch/NavBarSearchUserRow.tsxapps/meteor/client/navbar/NavBarSettingsToolbar/UserMenu/EditStatusModal.tsxapps/meteor/client/navbar/NavBarSearch/NavBarSearchItemWithData.tsxapps/meteor/client/navbar/NavBarSearch/NavBarSearchItem.tsxapps/meteor/client/sidebar/footer/SidebarFooterDefault.tsxapps/meteor/client/sidebar/footer/SidebarFooterWatermark.tsxapps/meteor/client/sidebar/RoomList/SidebarItemTemplateWithData.tsxapps/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.tsxapps/meteor/client/sidebar/hooks/usePreventDefault.tsapps/meteor/client/sidebar/hooks/useShortcutOpenMenu.tsapps/meteor/client/portals/VideoConfPopupPortal.tsxapps/meteor/client/navbar/NavBarSearch/NavBarSearchRow.tsxapps/meteor/client/navbar/NavBarSearch/NavBarSearchUserRow.tsxapps/meteor/client/navbar/NavBarSettingsToolbar/UserMenu/EditStatusModal.tsxapps/meteor/client/navbar/NavBarSearch/NavBarSearchItemWithData.tsxapps/meteor/client/navbar/NavBarSearch/NavBarSearchItem.tsxapps/meteor/client/sidebar/footer/SidebarFooterDefault.tsxapps/meteor/client/sidebar/footer/SidebarFooterWatermark.tsxapps/meteor/client/sidebar/RoomList/SidebarItemTemplateWithData.tsxapps/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.tsapps/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.tsapps/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.tsapps/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.tsapps/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
Proposed changes (including videos or screenshots)
As a first step towards upgrading to React 19, it handles types from
@types/reactlooking 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