Skip to content

Commit

Permalink
Fix: Resolve the issue of conflict between Chinese input method and E…
Browse files Browse the repository at this point in the history
…nter key. (#435)

* fix:修复中文输入法enter键冲突的问题

* Fix: Resolve the issue of conflict between Chinese input method and Enter key.
  • Loading branch information
fangxiao committed Apr 6, 2023
1 parent aa10590 commit 9006178
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/components/markdown.tsx
Expand Up @@ -723,7 +723,13 @@ export function CommandBarInner({ autofocus }: { autofocus: boolean }) {
// ref = {textareaRef}
innerRef={(ref) => void (textareaRef.current.value = ref)}
onKeyDown={(e) => {
if (!e.shiftKey && e.key === 'Enter') {
/**
* 问题 兼容中文输入法时的冲突问题,中文输入法时enter键对应keycode是229,中文输入法关闭的时候keycode为13,所以增加一个keycode为13的条件即能解决此问题
* 修改人:方晓
* 公司:神策数据
* 修改时间:2023年4月5号
*/
if (!e.shiftKey && e.key === 'Enter' && e.keyCode == 13) {
// Don't submit an empty prompt
if (textareaRef.current.value!.value.trim().length > 0) {
dispatch(ct.submitCommandBar(null))
Expand Down

0 comments on commit 9006178

Please sign in to comment.