Skip to content

Commit 2f43f96

Browse files
authored
Main (#17393)
* fix(rn): keyboard height on hide * fix(rn): 空字符串时,输入中文异常
1 parent f9a84d1 commit 2f43f96

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

packages/taro-components-rn/src/components/Input/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ const _Input = (props: InputProps) => {
121121
if (typeof result === 'string') {
122122
tmpValue.current = result
123123
setReturnValue(result)
124-
} else if (returnValue) {
124+
} else if (returnValue !== undefined) {
125125
// 为了处理输入不合法,setState 相同值时,状态不更新,UI 也得不到更新,重置状态进而更新
126126
setReturnValue(undefined)
127127
}

packages/taro-rn/src/lib/keyboard.ts

+9-9
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ const hideKeyboard = (opts: Taro.hideKeyboard.Option = {}): Promise<TaroGeneral.
1717
const _cbManager = createCallbackManager()
1818
let _hasListener = false
1919

20-
const keyboardHeightListener = (e) => {
21-
_cbManager.trigger({ height: e.endCoordinates.height })
20+
const keyboardHeightListener = (height: number) => {
21+
_cbManager.trigger({ height })
2222
}
2323

2424
/**
@@ -28,8 +28,12 @@ const keyboardHeightListener = (e) => {
2828
const onKeyboardHeightChange = (callback: Taro.onKeyboardHeightChange.Callback): void => {
2929
_cbManager.add(callback)
3030
if (!_hasListener) {
31-
Keyboard.addListener('keyboardDidShow', keyboardHeightListener)
32-
Keyboard.addListener('keyboardDidHide', keyboardHeightListener)
31+
Keyboard.addListener('keyboardDidShow', (e) => {
32+
keyboardHeightListener(e.endCoordinates.height)
33+
})
34+
Keyboard.addListener('keyboardDidHide', () => {
35+
keyboardHeightListener(0)
36+
})
3337
_hasListener = true
3438
}
3539
}
@@ -53,8 +57,4 @@ const offKeyboardHeightChange = (callback?: Taro.onKeyboardHeightChange.Callback
5357
}
5458
}
5559

56-
export {
57-
hideKeyboard,
58-
offKeyboardHeightChange,
59-
onKeyboardHeightChange
60-
}
60+
export { hideKeyboard, offKeyboardHeightChange, onKeyboardHeightChange }

0 commit comments

Comments
 (0)