Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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);
Comment thread
huult marked this conversation as resolved.
Resolved

useEffect(() => {
setFilteredEmojis(allEmojis);
Expand Down
9 changes: 8 additions & 1 deletion src/styles/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down