From 5d20f91c9fce548512bc09d6fe1f0eec2a725400 Mon Sep 17 00:00:00 2001 From: tony chen Date: Mon, 3 Mar 2025 15:30:37 +0800 Subject: [PATCH 1/2] fix(rn): keyboard height on hide --- packages/taro-rn/src/lib/keyboard.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/taro-rn/src/lib/keyboard.ts b/packages/taro-rn/src/lib/keyboard.ts index 42a4253a222c..b35da35b303b 100644 --- a/packages/taro-rn/src/lib/keyboard.ts +++ b/packages/taro-rn/src/lib/keyboard.ts @@ -17,8 +17,8 @@ const hideKeyboard = (opts: Taro.hideKeyboard.Option = {}): Promise { - _cbManager.trigger({ height: e.endCoordinates.height }) +const keyboardHeightListener = (height: number) => { + _cbManager.trigger({ height }) } /** @@ -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 } } @@ -53,8 +57,4 @@ const offKeyboardHeightChange = (callback?: Taro.onKeyboardHeightChange.Callback } } -export { - hideKeyboard, - offKeyboardHeightChange, - onKeyboardHeightChange -} +export { hideKeyboard, offKeyboardHeightChange, onKeyboardHeightChange } From 112515907b44dd0df91ee9d4335329e45d422737 Mon Sep 17 00:00:00 2001 From: tony chen Date: Mon, 3 Mar 2025 18:40:04 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix(rn):=20=E7=A9=BA=E5=AD=97=E7=AC=A6?= =?UTF-8?q?=E4=B8=B2=E6=97=B6=EF=BC=8C=E8=BE=93=E5=85=A5=E4=B8=AD=E6=96=87?= =?UTF-8?q?=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/taro-components-rn/src/components/Input/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/taro-components-rn/src/components/Input/index.tsx b/packages/taro-components-rn/src/components/Input/index.tsx index e66fb5a3c872..3df930ac5e5c 100644 --- a/packages/taro-components-rn/src/components/Input/index.tsx +++ b/packages/taro-components-rn/src/components/Input/index.tsx @@ -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) }