-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[RNMobile] Handle floating keyboard case (#33089)
* Handle floating keyboard case in KeyboardAvoidingView * Handle floating keyboard case in bottom sheet * Update react-native-editor changelog
- Loading branch information
Showing
4 changed files
with
44 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
packages/components/src/mobile/utils/use-is-floating-keyboard.native.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { Keyboard, Dimensions } from 'react-native'; | ||
|
||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { useEffect, useState } from '@wordpress/element'; | ||
|
||
export default function useIsFloatingKeyboard() { | ||
const windowWidth = Dimensions.get( 'window' ).width; | ||
|
||
const [ floating, setFloating ] = useState( false ); | ||
|
||
useEffect( () => { | ||
const onKeyboardWillChangeFrame = ( event ) => { | ||
setFloating( event.endCoordinates.width !== windowWidth ); | ||
}; | ||
|
||
Keyboard.addListener( | ||
'keyboardWillChangeFrame', | ||
onKeyboardWillChangeFrame | ||
); | ||
return () => { | ||
Keyboard.removeListener( | ||
'keyboardWillChangeFrame', | ||
onKeyboardWillChangeFrame | ||
); | ||
}; | ||
}, [ windowWidth ] ); | ||
|
||
return floating; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters