Skip to content

fix(sender): avoid submit after composition end in safari#1732

Open
IsDyh01 wants to merge 3 commits intoant-design:mainfrom
IsDyh01:fix/sender-combined-submit-error
Open

fix(sender): avoid submit after composition end in safari#1732
IsDyh01 wants to merge 3 commits intoant-design:mainfrom
IsDyh01:fix/sender-combined-submit-error

Conversation

@IsDyh01
Copy link
Contributor

@IsDyh01 IsDyh01 commented Feb 5, 2026

中文版模板 / Chinese template

🤔 This is a ...

  • 🆕 New feature
  • [✅] 🐞 Bug fix
  • 📝 Site / documentation improvement
  • 📽️ Demo improvement
  • 💄 Component style improvement
  • 🤖 TypeScript definition improvement
  • 📦 Bundle size optimization
  • ⚡️ Performance optimization
  • ⭐️ Feature enhancement
  • 🌐 Internationalization
  • 🛠 Refactoring
  • 🎨 Code style optimization
  • ✅ Test Case
  • 🔀 Branch merge
  • ⏩ Workflow
  • ⌨️ Accessibility improvement
  • ❓ Other (about what?)

🔗 Related Issues

#1700

  • Describe the source of related requirements, such as links to relevant issue discussions.
  • For example: close #xxxx, fix #xxxx

💡 Background and Solution

  • The specific problem to be addressed.
  • List the final API implementation and usage if needed.
  • If there are UI/interaction changes, consider providing screenshots or GIFs.

📝 Change Log

Language Changelog
🇺🇸 English
🇨🇳 Chinese

Summary by CodeRabbit

  • 错误修复
    • 优化文本输入区域中 Enter 键的处理:在输入法(如中文、日文)组合结束后的短时间内(约100毫秒)按 Enter 不再误触提交,避免在组合刚结束时意外发送消息。

@github-actions
Copy link
Contributor

github-actions bot commented Feb 5, 2026

Preview is ready

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @IsDyh01, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request resolves a bug where pressing Enter immediately after an IME composition finishes could lead to an unintended form submission, particularly in Safari. The fix introduces a short delay after composition ends to differentiate between a composition completion and an intentional Enter key press for submission, thereby improving the reliability of text input in the TextArea component.

Highlights

  • Safari Composition Bug Fix: Implemented a mechanism to prevent accidental form submission immediately after an input method editor (IME) composition ends, specifically addressing an issue observed in Safari browsers.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • packages/x/components/sender/components/TextArea.tsx
    • Introduced a lastCompositionEndTick ref to record the timestamp when an input method editor (IME) composition ends.
    • Modified the onInternalCompositionEnd handler to update the lastCompositionEndTick with the current time.
    • Updated the onInternalKeyDown handler to include a new condition that prevents form submission if an Enter key press occurs within 100 milliseconds of an IME composition ending, mitigating a specific bug in Safari.
Activity
  • No specific activity (comments, reviews, or progress updates) has been recorded for this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@dosubot dosubot bot added the bug Something isn't working label Feb 5, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 5, 2026

📝 Walkthrough

Walkthrough

在 TextArea 中添加了对输入法组合(composition)结束后的短暂冷却:记录最近一次 compositionend 的时间戳,并在 Enter 键处理时若在 100ms 内刚结束组合则阻止提交。新增单元测试覆盖该场景。

Changes

Cohort / File(s) Summary
组合事件冷却机制
packages/x/components/sender/components/TextArea.tsx
新增内部 ref lastCompositionEndTick,在 compositionend 更新时间戳;在 Enter 键处理逻辑中加入 100ms 冷却校验以避免组合刚结束时触发提交。
测试覆盖
packages/x/components/sender/__tests__/index.test.tsx
新增测试:在 compositionStart → compositionEnd 后 100ms 内按 Enter(无 Shift)不应触发 onSubmit。

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 分钟

诗歌

🐰 小小时间戳,静守片刻宁静

组合落笔处,Enter 暂缓轻声应
百毫秒的温柔,避免误触惊醒
兔兔在角落,悄悄修好每一行 ✨

🚥 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 标题清晰准确地总结了主要变更:修复在Safari中composition事件后避免提交的问题,与代码变更内容完全相关。
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.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a fix to prevent unintended form submission after an IME composition ends, a known issue in Safari. The approach of using a timestamp to create a small debounce period after compositionend is a sound solution. My feedback focuses on improving code maintainability by replacing a magic number with a named constant, which will make the code clearer and easier to manage.

@codecov
Copy link

codecov bot commented Feb 5, 2026

Bundle Report

Changes will increase total bundle size by 68 bytes (0.0%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
antdx-array-push 1.91MB 68 bytes (0.0%) ⬆️

Affected Assets, Files, and Routes:

view changes for bundle: antdx-array-push

Assets Changed:

Asset Name Size Change Total Size Change (%)
antdx.min.js 68 bytes 1.91MB 0.0%

@codecov
Copy link

codecov bot commented Feb 5, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.41%. Comparing base (e77f65a) to head (3e24d03).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1732      +/-   ##
==========================================
+ Coverage   97.34%   97.41%   +0.06%     
==========================================
  Files         144      144              
  Lines        4598     4606       +8     
  Branches     1295     1307      +12     
==========================================
+ Hits         4476     4487      +11     
+ Misses        120      117       -3     
  Partials        2        2              

☔ View full report in Codecov by Sentry.
📢 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.

@kimteayon
Copy link
Collaborator

我研究下 应该有特性判断

@IsDyh01
Copy link
Contributor Author

IsDyh01 commented Feb 6, 2026

我研究下 应该有特性判断

是不是可以通过keyocde=229来判断,不管是safari还是google那些浏览器,只要是组合状态下keycode都为229

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants