react-component / react-component/input

在 Mac 系统上使用中文输入法时,onPressEnter 是否存在问题?

Open
#26 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
44
Forks
56
Avg merge
20h 6m
Merged PRs (30d)
1

Description

公司项目使用了 Antd,而 Antd 依赖了 rc-input 的代码。通过查看源码后发现 onPressEnter 使用了 onkeydown 实现检查是否按下 Enter,但这种实现会导致在 Mac 系统上使用中文输入法的情况下,输入任意内容不选择任何联想项时按下 Enter 键,会触发对应逻辑,正常情况下应该不做处理?个人尝试后发现使用 onkeypress 是没有问题的。

这是我写的 最小复现 Demo,如果使用非 onkeypress 的方式捕获,则会触发此问题,Windows 貌似没有出现此问题。

rc-input 的最小复现

https://user-images.githubusercontent.com/25198337/197444497-1e93cdf7-37ed-4bdd-a8c8-1bd70fa5bf5c.mp4

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the onkeydown handler in src/Input.tsx around line 86, then reproduce the behavior using the linked rc-input CodeSandbox or the Mac Chinese-input-method demo. Done means pressing Enter without selecting a suggestion does not trigger onPressEnter during composition, while ordinary Enter handling still works.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.