Skip to content

fix: use textContent instead of innerText for emoji span parsing#39059

Open
dodaa08 wants to merge 3 commits into
RocketChat:developfrom
dodaa08:InnertextTotextContent
Open

fix: use textContent instead of innerText for emoji span parsing#39059
dodaa08 wants to merge 3 commits into
RocketChat:developfrom
dodaa08:InnertextTotextContent

Conversation

@dodaa08
Copy link
Copy Markdown
Contributor

@dodaa08 dodaa08 commented Feb 25, 2026

Proposed changes (including videos or screenshots)

Replaced innerText with textContent in detectEmoji when reading emoji span text. textContent avoids unnecessary layout reflow and better expresses the intent of just reading raw text content.

Steps to test or reproduce

Run the emoji autocomplete in the message input and verify emoji suggestions render correctly.

Further comments

The change is minimal and behavior remains identical in practice both innerText and textContent return the same value for emoji spans

Summary by CodeRabbit

  • Bug Fixes
    • Improved emoji detection consistency and reliability across different browser environments through enhanced content extraction methods.

@dodaa08 dodaa08 requested a review from a team as a code owner February 25, 2026 17:25
@dionisio-bot
Copy link
Copy Markdown
Contributor

dionisio-bot Bot commented Feb 25, 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

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Feb 25, 2026

⚠️ No Changeset found

Latest commit: fbfeb00

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
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 25, 2026

Walkthrough

This change replaces innerText with textContent in the detectEmoji utility function when extracting text content from a span element. The function signature and exported API remain unchanged.

Changes

Cohort / File(s) Summary
Emoji Detection Utility
apps/meteor/client/lib/utils/detectEmoji.ts
Replaced span.innerText with span.textContent ?? '' for extracting content property in emoji detection objects.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Suggested labels

type: chore

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 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 innerText with textContent in the emoji detection utility, which directly matches the code modification in detectEmoji.ts.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


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

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
apps/meteor/client/lib/utils/detectEmoji.ts (1)

13-13: Consider ?? over || for clarity, but no behavioral issues.

The change from innerText to textContent is sound. Since the div is a detached (off-document) element, innerText is unreliable — it attempts to compute CSS-based layout on elements not in the live DOM, which yields implementation-dependent results. textContent is the correct choice here and avoids unnecessary reflow.

The content field is rendered as JSX children in Fuselage emoji components (EmojiRenderer.tsx). Emoji content is typically a single Unicode character or short notation, so any whitespace differences between the two APIs are negligible in practice.

One optional improvement: use ?? instead of || for semantic precision — textContent returns null only for document/doctype nodes, never for element nodes, so the guard is redundant, but ?? is more semantically explicit about a null check:

-		content: span.textContent || '',
+		content: span.textContent ?? '',
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/meteor/client/lib/utils/detectEmoji.ts` at line 13, Replace the fallback
operator on the content field to use the nullish coalescing operator so the
expression reads as a null check for span.textContent; update the line
referencing span.textContent || '' to use ?? instead (the unique symbols to
change are the content property assignment and the span.textContent expression
in detectEmoji.ts) to make the intent explicit without changing behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@apps/meteor/client/lib/utils/detectEmoji.ts`:
- Line 13: Replace the fallback operator on the content field to use the nullish
coalescing operator so the expression reads as a null check for
span.textContent; update the line referencing span.textContent || '' to use ??
instead (the unique symbols to change are the content property assignment and
the span.textContent expression in detectEmoji.ts) to make the intent explicit
without changing behavior.

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8d73ce5 and 5eab909.

📒 Files selected for processing (1)
  • apps/meteor/client/lib/utils/detectEmoji.ts
📜 Review details
🧰 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/lib/utils/detectEmoji.ts
🧠 Learnings (1)
📚 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/lib/utils/detectEmoji.ts

@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 25, 2026

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 70.62%. Comparing base (b1925d6) to head (fbfeb00).

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #39059      +/-   ##
===========================================
- Coverage    70.68%   70.62%   -0.07%     
===========================================
  Files         3190     3190              
  Lines       112732   112732              
  Branches     20448    20388      -60     
===========================================
- Hits         79689    79615      -74     
- Misses       30996    31065      +69     
- Partials      2047     2052       +5     
Flag Coverage Δ
e2e 60.37% <0.00%> (-0.04%) ⬇️
e2e-api 47.79% <ø> (-1.09%) ⬇️
unit 71.23% <0.00%> (-0.05%) ⬇️

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.

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.

1 participant