diff --git a/packages/webpack-plugin/lib/runtime/components/react/mpx-input.tsx b/packages/webpack-plugin/lib/runtime/components/react/mpx-input.tsx index cfc1f4f044..233029871e 100644 --- a/packages/webpack-plugin/lib/runtime/components/react/mpx-input.tsx +++ b/packages/webpack-plugin/lib/runtime/components/react/mpx-input.tsx @@ -283,7 +283,16 @@ const Input = forwardRef, FinalInputProps const setKeyboardAvoidContext = () => { if (keyboardAvoid) { - keyboardAvoid.current = { cursorSpacing, ref: nodeRef, adjustPosition, holdKeyboard } + keyboardAvoid.current = { + cursorSpacing, + ref: nodeRef, + adjustPosition, + holdKeyboard, + // fix: iOS 会在 onFocus 之前触发 keyboardWillShow 并且赋值 keyboardHeight + // 这里手动同步下 keyboardHeight,防止 onFocus setKeyboardAvoidContext 删掉 keyboardHeight + // 导致 iOS 后续 bindfoucus 触发条件失败 + keyboardHeight: keyboardAvoid?.current?.keyboardHeight + } } } @@ -318,6 +327,9 @@ const Input = forwardRef, FinalInputProps if (keyboardAvoid?.current?.onKeyboardShow) { keyboardAvoid.current.onKeyboardShow = undefined } + if (keyboardAvoid?.current?.keyboardHeight) { + keyboardAvoid.current.keyboardHeight = undefined + } } if (keyboardAvoid?.current) { // 有 keyboardAvoiding