Skip to content

fix(MessageComposer): make textarea full-width in custom composer layouts#3241

Merged
oliverlaz merged 2 commits into
masterfrom
fix/composer-textarea-full-width
Jul 14, 2026
Merged

fix(MessageComposer): make textarea full-width in custom composer layouts#3241
oliverlaz merged 2 commits into
masterfrom
fix/composer-textarea-full-width

Conversation

@oliverlaz

@oliverlaz oliverlaz commented Jul 13, 2026

Copy link
Copy Markdown
Member

🎯 Goal

The message composer <textarea> does not fill its container when the SDK is integrated into a custom composer layout — it collapses to ~160px — even though it stretches correctly in our own example apps.

Root cause: the rules that give the composer textarea its width live only inside the .str-chat__message-composer-controls wrapper, scoped as:

.str-chat .str-chat__message-composer-controls .str-chat__textarea textarea { width: 100%; }

.str-chat__textarea and its <textarea> are rendered by TextareaComposer, but a custom composer that renders <TextareaComposer> without the default MessageComposerUI never produces the .str-chat__message-composer-controls wrapper. So the selector never matches, no width is applied, and the bare <textarea> falls back to its intrinsic cols=20 width (~160px). Our example apps use the default MessageComposerUI, so the wrapper is present and the bug is invisible there.

This is a recurring integration pain point, hence fixing it in the SDK rather than asking each integrator to re-add the width rule.

🛠 Implementation details

Lifted the .str-chat__textarea block out of the .str-chat__message-composer-controls wrapper in MessageComposer.scss so it is scoped to the TextareaComposer's own elements (.str-chat .str-chat__textarea / .str-chat .str-chat__textarea textarea) instead of the composer-controls layout wrapper.

Why this is safe:

  • .str-chat__textarea and its <textarea> are rendered only by TextareaComposer, and no other rule targets .str-chat__textarea, so lowering selector specificity from (0,3,1) to (0,2,1) conflicts with nothing.
  • flex: 1 on the wrapper is ignored when its parent isn't a flex container (custom composers) and continues to work in the default composer where the parent is display: flex.
  • The default MessageComposerUI already had all of these declarations applied, so its rendering is unchanged.

Net effect: any composer that renders <TextareaComposer> now gets a full-width textarea, with or without the default MessageComposerUI.

🎨 UI Changes

Verified live in a custom (Slack-style) composer that renders <TextareaComposer> without MessageComposerUI:

  • Before: composer <textarea> computed width = 160px (intrinsic cols=20 fallback).
  • After: composer <textarea> computed width = 1059px — fills the composer container; the placeholder spans the full width.

No visual change in the default composer (MessageComposerUI), which already carried these styles.

Summary by CodeRabbit

  • Bug Fixes
    • Improved message composer layout consistency by ensuring the text area consistently fills available space across different composer configurations.
    • Preserved the existing text area look and behavior, including typography, sizing, scrollbar handling, and focus-visible styling.

…outs

Scope the .str-chat__textarea sizing rules to the TextareaComposer's own
elements instead of the .str-chat__message-composer-controls wrapper, so a
custom composer that renders <TextareaComposer> without the default
MessageComposerUI still gets a full-width textarea rather than the bare
<textarea> falling back to its intrinsic cols width (~160px).
@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 244b1efa-42d1-436a-a728-2f9e381275a0

📥 Commits

Reviewing files that changed from the base of the PR and between c5dc66d and 4cc6b57.

📒 Files selected for processing (1)
  • src/components/MessageComposer/styling/MessageComposer.scss
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/components/MessageComposer/styling/MessageComposer.scss

📝 Walkthrough

Walkthrough

The textarea styling block was moved and explicitly scoped in MessageComposer.scss. Existing typography, sizing, transparency, border, resize, shadow, and scrollbar rules were preserved, with an added focus-visible outline reset.

Changes

Textarea composer styling

Layer / File(s) Summary
Textarea layout and styling scope
src/components/MessageComposer/styling/MessageComposer.scss
The earlier textarea rules were removed and reintroduced in the TextareaComposer scope, retaining the visual reset and adding :focus-visible { outline: none; }.

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

Suggested reviewers: arnautov-anton

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately summarizes the main change: making the MessageComposer textarea full-width in custom layouts.
Description check ✅ Passed The description follows the template and covers the goal, implementation details, and UI changes with concrete verification notes.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/composer-textarea-full-width

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

github-actions Bot commented Jul 13, 2026

Copy link
Copy Markdown

Size Change: +1 B (0%)

Total Size: 880 kB

📦 View Changed
Filename Size Change
dist/css/index.css 41.4 kB +1 B (0%)
ℹ️ View Unchanged
Filename Size
dist/cjs/audioProcessing.js 1.74 kB
dist/cjs/channel-detail.js 22.9 kB
dist/cjs/emojis.js 2.56 kB
dist/cjs/index.js 292 kB
dist/cjs/mp3-encoder.js 814 B
dist/cjs/ReactPlayerWrapper.js 547 B
dist/cjs/useChannelHeaderOnlineStatus.js 41 kB
dist/cjs/useMessageComposerController.js 1.01 kB
dist/cjs/useNotificationApi.js 57.5 kB
dist/css/channel-detail.css 2.84 kB
dist/css/emoji-picker.css 178 B
dist/css/emoji-replacement.css 456 B
dist/es/audioProcessing.mjs 1.65 kB
dist/es/channel-detail.mjs 22.6 kB
dist/es/emojis.mjs 2.48 kB
dist/es/index.mjs 290 kB
dist/es/mp3-encoder.mjs 768 B
dist/es/ReactPlayerWrapper.mjs 485 B
dist/es/useChannelHeaderOnlineStatus.mjs 40.5 kB
dist/es/useMessageComposerController.mjs 935 B
dist/es/useNotificationApi.mjs 56.1 kB

compressed-size-action

@codecov

codecov Bot commented Jul 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.21%. Comparing base (2c70879) to head (4cc6b57).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3241      +/-   ##
==========================================
+ Coverage   85.18%   85.21%   +0.03%     
==========================================
  Files         505      505              
  Lines       15784    15784              
  Branches     5010     5010              
==========================================
+ Hits        13446    13451       +5     
+ Misses       2338     2333       -5     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/components/MessageComposer/styling/MessageComposer.scss (1)

247-272: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consider using .str-chat__textarea__textarea class selector instead of bare textarea for robustness.

Relocating the block from .str-chat__message-composer-controls to the top level reduces the nested textarea selector's specificity from (0,0,3,1) to (0,0,2,1). Using the class .str-chat__textarea__textarea — which TextareaComposer already applies — would raise specificity to (0,0,3,0) and make targeting more intentional, compensating for the parent specificity drop.

♻️ Proposed refactor
     textarea {
+    .str-chat__textarea__textarea {
       background: transparent;
🤖 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 `@src/components/MessageComposer/styling/MessageComposer.scss` around lines 247
- 272, Update the nested selector inside .str-chat__textarea to target the
existing .str-chat__textarea__textarea class instead of the bare textarea
element, preserving the current input styles while restoring intentional
specificity after moving the block to the top level.
🤖 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.

Nitpick comments:
In `@src/components/MessageComposer/styling/MessageComposer.scss`:
- Around line 247-272: Update the nested selector inside .str-chat__textarea to
target the existing .str-chat__textarea__textarea class instead of the bare
textarea element, preserving the current input styles while restoring
intentional specificity after moving the block to the top level.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 54571bb1-c367-4869-85c7-680a61b00705

📥 Commits

Reviewing files that changed from the base of the PR and between 3bb8a2f and c5dc66d.

📒 Files selected for processing (1)
  • src/components/MessageComposer/styling/MessageComposer.scss

… fix

Loosening the .str-chat__textarea selector dropped its specificity from
(0,3,1) to (0,2,1), which let the global `.str-chat *:focus-visible`
outline rule (base.scss, (0,3,0)) override the textarea's `outline: none`
and show a focus ring. Re-assert the reset on :focus-visible so it lands at
(0,3,1) and keeps outranking the global outline.
@oliverlaz oliverlaz merged commit 05236db into master Jul 14, 2026
14 checks passed
@oliverlaz oliverlaz deleted the fix/composer-textarea-full-width branch July 14, 2026 09:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants