Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 修复部分情况keypress不触发,导致输入异常的问题 #4745

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/core/src/text-area/event-handlers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
handleCompositionUpdate,
} from './composition'
import handleOnKeydown from './keydown'
import handleKeypress from './keypress'
import handleInput from './input'
import handleOnCopy from './copy'
import handleOnCut from './cut'
import handleOnPaste from './paste'
Expand All @@ -29,7 +29,7 @@ const eventConf = {
compositionend: handleCompositionEnd,
compositionupdate: handleCompositionUpdate,
keydown: handleOnKeydown,
keypress: handleKeypress,
input: handleInput,
copy: handleOnCopy,
cut: handleOnCut,
paste: handleOnPaste,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { hasEditableTarget } from '../helpers'

// 【注意】虽然 keypress 事件已经过时(建议用 keydown 取代),但这里是为了兼容 beforeinput ,所以不会在高级浏览器生效,不用升级 keydown

function handleKeypress(event: Event, textarea: TextArea, editor: IDomEditor) {
function handleInput(event: Event, textarea: TextArea, editor: IDomEditor) {
// 这里是兼容不完全支持 beforeInput 的浏览器。对于支持 beforeInput 的浏览器,会用 beforeinput 事件处理
if (HAS_BEFORE_INPUT_SUPPORT) return

Expand All @@ -27,4 +27,4 @@ function handleKeypress(event: Event, textarea: TextArea, editor: IDomEditor) {
Editor.insertText(editor, text)
}

export default handleKeypress
export default handleInput