Skip to content

fix(livechat): type Menu ref and remove legacy base usage#40126

Open
probeen007 wants to merge 3 commits intoRocketChat:developfrom
probeen007:fix/livechat-menu-ref-typing-39128
Open

fix(livechat): type Menu ref and remove legacy base usage#40126
probeen007 wants to merge 3 commits intoRocketChat:developfrom
probeen007:fix/livechat-menu-ref-typing-39128

Conversation

@probeen007
Copy link
Copy Markdown

@probeen007 probeen007 commented Apr 13, 2026

Proposed changes

Fix LiveChat Menu ref typing to use the actual DOM element contract instead of any. PopoverMenuWrapper now stores a HTMLDivElement | null ref and reads bounds directly from the element with getBoundingClientRect(), removing the legacy .base component-instance dependency.

Issue(s)

Closes #39128

Steps to test or reproduce

  1. Open packages/livechat/src/components/Menu/index.tsx
  2. Confirm MenuProps uses ref?: Ref
  3. Confirm PopoverMenuWrapper stores HTMLDivElement | null
  4. Confirm bounds are read with this.menuRef?.getBoundingClientRect()
  5. Run corepack yarn workspace @rocket.chat/livechat run lint src/components/Menu/index.tsx

Further comments

This change is intentionally scoped to the ref-typing issue reported in #39128. It improves type safety without changing runtime behavior.

Summary by CodeRabbit

  • Refactor
    • Enhanced type safety and code stability in the Menu component for improved reliability.

@probeen007 probeen007 requested review from a team as code owners April 13, 2026 14:00
@dionisio-bot
Copy link
Copy Markdown
Contributor

dionisio-bot Bot commented Apr 13, 2026

Looks like this PR is not ready to merge, because of the following issues:

  • This PR is missing the 'stat: QA assured' label
  • This PR is missing the required milestone or project

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 13, 2026

CLA assistant check
All committers have signed the CLA.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 13, 2026

Walkthrough

The Menu component in LiveChat was refactored to improve type safety by replacing the untyped any ref with a properly typed Ref<HTMLDivElement>. Internal ref storage and access patterns were updated to work directly with DOM elements instead of relying on legacy component instance shapes.

Changes

Cohort / File(s) Summary
Menu Component Type Safety
packages/livechat/src/components/Menu/index.tsx
Updated MenuProps.ref from untyped any to Ref<HTMLDivElement>, changed internal menuRef storage from component instance shape to direct `HTMLDivElement

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested labels

type: chore

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and specifically describes the main change: replacing untyped 'any' refs with properly typed HTMLDivElement refs and removing legacy '.base' component shape usage.
Linked Issues check ✅ Passed All coding requirements from #39128 are met: MenuProps.ref is now typed as Ref, PopoverMenuWrapper stores HTMLDivElement | null instead of component instance, and bounds retrieval uses direct getBoundingClientRect() call.
Out of Scope Changes check ✅ Passed All changes are scoped to the Menu component ref typing and PopoverMenuWrapper ref handling as specified in #39128, with no unrelated modifications.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

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


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.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

No issues found across 1 file

@probeen007
Copy link
Copy Markdown
Author

probeen007 commented Apr 13, 2026

Hi maintainers, this PR is ready from my side.
Could you please add:

label: stat: QA assured
required milestone/project
I do not have permission to set these on this repository PR. Thanks.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 13, 2026

Tip

For best results, initiate chat on the files or code changes.

@probeen007 Unfortunately, I'm not able to add labels (such as stat: QA assured) or assign milestones/projects to this PR — those actions require repository maintainers or collaborators with write access to the RocketChat/Rocket.Chat repository.

Here are a few suggestions to get their attention:

  1. Ping maintainers directly in the PR comments (e.g., tag the Rocket.Chat core team or the relevant squad lead).
  2. Check the PR guidelines for the correct channel or process to request label/milestone assignment.
  3. Reach out on the Rocket.Chat open server (e.g., the #dev or #contributing channel) to ask a maintainer to set these for you.

The code changes in this PR look well-scoped and the pre-merge checks are all passing — hopefully a maintainer can take a look and set the required metadata soon! 🙌


🧠 Learnings used
Learnt from: ggazzo
Repo: RocketChat/Rocket.Chat PR: 35995
File: apps/meteor/app/api/server/v1/rooms.ts:1107-1112
Timestamp: 2026-02-23T17:53:18.785Z
Learning: In Rocket.Chat PR reviews, maintain strict scope boundaries—when a PR is focused on a specific endpoint (e.g., rooms.favorite), avoid reviewing or suggesting changes to other endpoints that were incidentally refactored (e.g., rooms.invite) unless explicitly requested by maintainers.

Learnt from: juliajforesti
Repo: RocketChat/Rocket.Chat PR: 38493
File: apps/meteor/tests/e2e/page-objects/fragments/home-content.ts:60-82
Timestamp: 2026-02-24T19:36:55.089Z
Learning: In RocketChat/Rocket.Chat e2e tests (apps/meteor/tests/e2e/page-objects/fragments/home-content.ts), thread message preview listitems do not have aria-roledescription="message", so lastThreadMessagePreview locator cannot be scoped to messageListItems (which filters for aria-roledescription="message"). It should remain scoped to page.getByRole('listitem') or mainMessageList.getByRole('listitem').

Learnt from: smirk-dev
Repo: RocketChat/Rocket.Chat PR: 39625
File: apps/meteor/app/api/server/v1/push.ts:85-97
Timestamp: 2026-03-14T14:58:58.834Z
Learning: In RocketChat/Rocket.Chat, the `push.token` POST/DELETE endpoints in `apps/meteor/app/api/server/v1/push.ts` were already migrated to the chained router API pattern on `develop` prior to PR `#39625`. `cleanTokenResult` (which strips `authToken` and returns `PushTokenResult`) and `isPushTokenPOSTProps`/`isPushTokenDELETEProps` validators already exist on `develop`. PR `#39625` only migrates `push.get` and `push.info` to the chained pattern. Do not flag `cleanTokenResult` or `PushTokenResult` as newly introduced behavior-breaking changes when reviewing this PR.

@probeen007
Copy link
Copy Markdown
Author

Hi @julio-rocketchat , this PR is ready from my side.

Could you please add:

label: stat: QA assured
required milestone/project
I do not have permission to set these on this repository PR. Thanks.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 19, 2026

⚠️ No Changeset found

Latest commit: bdf5f83

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

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.

Fix usage of "any" in a LiveChat component

2 participants