textarea
textarea copied to clipboard
Input onChange trigger two times when input Chinese
As the figure shown, when input Chinese, onChange will trigger two times even input the single char.
This issue will cause relevant component issue like Ant-Mentions
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
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