Skip to content

Commit

Permalink
Main (#17393)
Browse files Browse the repository at this point in the history
* fix(rn): keyboard height on hide

* fix(rn): 空字符串时,输入中文异常
  • Loading branch information
zhiqingchen authored Mar 4, 2025
1 parent f9a84d1 commit 2f43f96
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion packages/taro-components-rn/src/components/Input/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ const _Input = (props: InputProps) => {
if (typeof result === 'string') {
tmpValue.current = result
setReturnValue(result)
} else if (returnValue) {
} else if (returnValue !== undefined) {
// 为了处理输入不合法,setState 相同值时,状态不更新,UI 也得不到更新,重置状态进而更新
setReturnValue(undefined)
}
Expand Down
18 changes: 9 additions & 9 deletions packages/taro-rn/src/lib/keyboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ const hideKeyboard = (opts: Taro.hideKeyboard.Option = {}): Promise<TaroGeneral.
const _cbManager = createCallbackManager()
let _hasListener = false

const keyboardHeightListener = (e) => {
_cbManager.trigger({ height: e.endCoordinates.height })
const keyboardHeightListener = (height: number) => {
_cbManager.trigger({ height })
}

/**
Expand All @@ -28,8 +28,12 @@ const keyboardHeightListener = (e) => {
const onKeyboardHeightChange = (callback: Taro.onKeyboardHeightChange.Callback): void => {
_cbManager.add(callback)
if (!_hasListener) {
Keyboard.addListener('keyboardDidShow', keyboardHeightListener)
Keyboard.addListener('keyboardDidHide', keyboardHeightListener)
Keyboard.addListener('keyboardDidShow', (e) => {
keyboardHeightListener(e.endCoordinates.height)
})
Keyboard.addListener('keyboardDidHide', () => {
keyboardHeightListener(0)
})
_hasListener = true
}
}
Expand All @@ -53,8 +57,4 @@ const offKeyboardHeightChange = (callback?: Taro.onKeyboardHeightChange.Callback
}
}

export {
hideKeyboard,
offKeyboardHeightChange,
onKeyboardHeightChange
}
export { hideKeyboard, offKeyboardHeightChange, onKeyboardHeightChange }

0 comments on commit 2f43f96

Please sign in to comment.