textarea icon indicating copy to clipboard operation
textarea copied to clipboard

Input onChange trigger two times when input Chinese

Open SocietyNiu opened this issue 1 month ago • 1 comments

As the figure shown, when input Chinese, onChange will trigger two times even input the single char. Image

This issue will cause relevant component issue like Ant-Mentions Image

This issue should be avoided, and the same issue has been resolved before with rc-input. Issue 46587 https://github.com/react-component/input/pull/61

SocietyNiu avatar Nov 04 '25 20:11 SocietyNiu

A summary of the changes CodeRabbit can apply:

  • Add a guard in src/TextArea.tsx to call triggerChange only when compositionRef.current is false (preventing onChange during IME composition) and add tests in tests/ime-composition.test.tsx to verify single onChange on Chinese IME input, normal input behavior, repeated compositions, and maxlength enforcement.

  • Add composition-aware change handling to src/TextArea.tsx (wrap triggerChange to skip calls while compositionRef.current is true) and introduce tests/tests for IME behavior by adding tests/ime-composition.test.tsx with unit tests ensuring onChange is suppressed during composition, fires once after composition end, handles multiple compositions, normal typing, and maxLength application after composition.

  • [ ] ✅ Create PR with these edits
  • [ ] 📋 Get copyable edits

coderabbitai[bot] avatar Nov 04 '25 20:11 coderabbitai[bot]