Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Main #17393

Merged
merged 2 commits into from
Mar 4, 2025
Merged

Main #17393

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 }
Loading