Browse Source

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

fix-keypress-no-support
TGuoW 3 years ago
parent
commit
60b7eb0654
  1. 4
      packages/core/src/text-area/event-handlers/index.ts
  2. 4
      packages/core/src/text-area/event-handlers/input.ts

4
packages/core/src/text-area/event-handlers/index.ts

@ -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'
@ -29,7 +29,7 @@ const eventConf = {
compositionend: handleCompositionEnd,
compositionupdate: handleCompositionUpdate,
keydown: handleOnKeydown,
keypress: handleKeypress,
input: handleInput,
copy: handleOnCopy,
cut: handleOnCut,
paste: handleOnPaste,

4
packages/core/src/text-area/event-handlers/keypress.ts → packages/core/src/text-area/event-handlers/input.ts

@ -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
@ -27,4 +27,4 @@ function handleKeypress(event: Event, textarea: TextArea, editor: IDomEditor) {
Editor.insertText(editor, text)
}
export default handleKeypress
export default handleInput
Loading…
Cancel
Save