diff --git a/src/components/EmojiPicker/EmojiPickerMenu/useEmojiPickerMenu.ts b/src/components/EmojiPicker/EmojiPickerMenu/useEmojiPickerMenu.ts index 0d8acd5eef38..336d7043d4ed 100644 --- a/src/components/EmojiPicker/EmojiPickerMenu/useEmojiPickerMenu.ts +++ b/src/components/EmojiPicker/EmojiPickerMenu/useEmojiPickerMenu.ts @@ -2,6 +2,7 @@ import type {FlashList} from '@shopify/flash-list'; import {useCallback, useEffect, useMemo, useRef, useState} from 'react'; import emojis from '@assets/emojis'; import {useFrequentlyUsedEmojis} from '@components/OnyxProvider'; +import useKeyboardState from '@hooks/useKeyboardState'; import useLocalize from '@hooks/useLocalize'; import usePreferredEmojiSkinTone from '@hooks/usePreferredEmojiSkinTone'; import useStyleUtils from '@hooks/useStyleUtils'; @@ -23,12 +24,15 @@ const useEmojiPickerMenu = () => { const [preferredSkinTone] = usePreferredEmojiSkinTone(); const {windowHeight} = useWindowDimensions(); const StyleUtils = useStyleUtils(); + const {keyboardHeight} = useKeyboardState(); + /** - * At EmojiPicker has set innerContainerStyle with maxHeight: '95%' by styles.popoverInnerContainer - * to avoid the list style to be cut off due to the list height being larger than the container height - * so we need to calculate listStyle based on the height of the window and innerContainerStyle at the EmojiPicker + * The EmojiPicker sets the `innerContainerStyle` with `maxHeight: '95%'` in `styles.popoverInnerContainer` + * to prevent the list from being cut off when the list height exceeds the container's height. + * To calculate the available list height, we subtract the keyboard height from the `windowHeight` + * to ensure the list is properly adjusted when the keyboard is visible. */ - const listStyle = StyleUtils.getEmojiPickerListHeight(isListFiltered, windowHeight * 0.95); + const listStyle = StyleUtils.getEmojiPickerListHeight(isListFiltered, windowHeight * 0.95 - keyboardHeight); useEffect(() => { setFilteredEmojis(allEmojis); diff --git a/src/styles/utils/index.ts b/src/styles/utils/index.ts index 88c20abf62cf..6d2ed885613a 100644 --- a/src/styles/utils/index.ts +++ b/src/styles/utils/index.ts @@ -933,9 +933,16 @@ function getEmojiPickerListHeight(isRenderingShortcutRow: boolean, windowHeight: if (windowHeight) { // dimensions of content above the emoji picker list const dimensions = isRenderingShortcutRow ? CONST.EMOJI_PICKER_TEXT_INPUT_SIZES + CONST.CATEGORY_SHORTCUT_BAR_HEIGHT : CONST.EMOJI_PICKER_TEXT_INPUT_SIZES; + const maxHeight = windowHeight - dimensions; return { ...style, - maxHeight: windowHeight - dimensions, + maxHeight, + /** + * On native platforms, `maxHeight` doesn't work as expected, so we manually + * enforce the height by returning the smaller of the element's height or the + * `maxHeight`, ensuring it doesn't exceed the maximum allowed. + */ + height: Math.min(style.height, maxHeight), }; } return style;