Skip to content

fix: resize uncontrolled textarea values - #84

Open
nrps9909 wants to merge 1 commit into
react-component:masterfrom
nrps9909:codex/uncontrolled-autosize
Open

fix: resize uncontrolled textarea values#84
nrps9909 wants to merge 1 commit into
react-component:masterfrom
nrps9909:codex/uncontrolled-autosize

Conversation

@nrps9909

@nrps9909nrps9909 commented Aug 28, 2026

Copy link
Copy Markdown

Summary

  • trigger autosize measurement from the merged textarea value
  • cover uncontrolled input changes through the existing internal measurement hook
  • preserve the existing controlled-value behavior

Problem

ResizableTextArea stores uncontrolled edits in internalValue, but its autosize layout effect depended only on the external value prop. With defaultValue or a fully uncontrolled textarea, typing changed mergedValue while value remained undefined, so startResize() was not triggered for the new content.

The regression test renders an uncontrolled autosizing textarea, clears the initial measurement call, and changes its DOM value. It receives zero measurement calls on current master and one after this change.

Validation

  • rc-test --runInBand (6 suites, 54 tests, 9 snapshots)
  • focused regression test
  • ESLint on src (no new errors; 2 existing hook warnings in the touched source)
  • Prettier and git diff --check

Existing repository checks

  • tsc --noEmit currently reports two existing jest-dom toHaveStyle matcher type errors in unchanged tests/index.spec.tsx lines 150 and 387.
  • father build currently stops on eight existing restricted internal imports in TextArea.tsx, ResizableTextArea.tsx, and interface.ts. This change adds no imports.

I checked all current open PR changed files and searched open issues/PRs for uncontrolled autosize work. #81 handles hidden-textarea tabindex, #78 handles IME change events, and #49 handles CSP styling; none overlaps this fix.

Summary by CodeRabbit

  • Bug Fixes

    • 修复非受控文本区域输入内容变化后未正确触发自动调整高度的问题。
    • 确保文本区域在内容更新时能够及时重新测量并适配尺寸。
  • Tests

    • 新增非受控模式下自动调整大小的测试,验证尺寸更新行为正常。

@coderabbitai

coderabbitaiBot commented Aug 28, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 3fb841cd-8c10-4f3e-a445-f02f8de05f23

📥 Commits

Reviewing files that changed from the base of the PR and between 7251dae and 1268bd2.

📒 Files selected for processing (2)
  • src/ResizableTextArea.tsx
  • tests/ResizableTextArea.test.tsx

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


Walkthrough

本次变更使 ResizableTextArea 在非受控值更新时重新执行自动尺寸测量,并新增测试验证 onInternalAutoSize 的调用次数。

Changes

自动尺寸测量

Layer / File(s)Summary
非受控值变化与自动尺寸测量
src/ResizableTextArea.tsx, tests/ResizableTextArea.test.tsx
useLayoutEffect 改用 mergedValue 作为依赖项。新增非受控输入测试,验证内容变化后 onInternalAutoSize 调用一次。

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

Merge Risk:⚪ Minimal · up to 1268b

This change makes uncontrolled textarea edits trigger the existing autosize measurement while preserving controlled behavior. No actionable merge-blocking risk remains beyond normal checks and review.

Poem

小兔发现文字长高高
改好依赖,测量重新跑
非受控输入轻轻跳
自动尺寸准确到
测试拍拍胡萝卜笑

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check nameStatusExplanation
Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
Title check✅ Passed标题准确概括了修复非受控 textarea 值变化时自动调整大小的问题。内容具体、简洁,并与代码和测试变更一致。
Docstring Coverage✅ PassedNo functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2…
Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes check✅ PassedCheck skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2 files.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

Some tools did not complete. Review the errors below.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

src/ResizableTextArea.tsx

ESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox.

tests/ResizableTextArea.test.tsx

ESLint skipped: the matched ESLint configuration already failed (missing-dependency).


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.

Sign up for freeto 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.

1 participant

@nrps9909