Skip to content

Commit b6414b3

Browse files
authored
Merge pull request #53806 from huult/53218-emoji-picker-no-dismiss-space
add dismiss space for emoji picker when searching
2 parents 567bd21 + 9b93483 commit b6414b3

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

src/components/EmojiPicker/EmojiPickerMenu/useEmojiPickerMenu.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import type {FlashList} from '@shopify/flash-list';
22
import {useCallback, useEffect, useMemo, useRef, useState} from 'react';
33
import emojis from '@assets/emojis';
44
import {useFrequentlyUsedEmojis} from '@components/OnyxProvider';
5+
import useKeyboardState from '@hooks/useKeyboardState';
56
import useLocalize from '@hooks/useLocalize';
67
import usePreferredEmojiSkinTone from '@hooks/usePreferredEmojiSkinTone';
78
import useStyleUtils from '@hooks/useStyleUtils';
@@ -23,12 +24,15 @@ const useEmojiPickerMenu = () => {
2324
const [preferredSkinTone] = usePreferredEmojiSkinTone();
2425
const {windowHeight} = useWindowDimensions();
2526
const StyleUtils = useStyleUtils();
27+
const {keyboardHeight} = useKeyboardState();
28+
2629
/**
27-
* At EmojiPicker has set innerContainerStyle with maxHeight: '95%' by styles.popoverInnerContainer
28-
* to avoid the list style to be cut off due to the list height being larger than the container height
29-
* so we need to calculate listStyle based on the height of the window and innerContainerStyle at the EmojiPicker
30+
* The EmojiPicker sets the `innerContainerStyle` with `maxHeight: '95%'` in `styles.popoverInnerContainer`
31+
* to prevent the list from being cut off when the list height exceeds the container's height.
32+
* To calculate the available list height, we subtract the keyboard height from the `windowHeight`
33+
* to ensure the list is properly adjusted when the keyboard is visible.
3034
*/
31-
const listStyle = StyleUtils.getEmojiPickerListHeight(isListFiltered, windowHeight * 0.95);
35+
const listStyle = StyleUtils.getEmojiPickerListHeight(isListFiltered, windowHeight * 0.95 - keyboardHeight);
3236

3337
useEffect(() => {
3438
setFilteredEmojis(allEmojis);

src/styles/utils/index.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -933,9 +933,16 @@ function getEmojiPickerListHeight(isRenderingShortcutRow: boolean, windowHeight:
933933
if (windowHeight) {
934934
// dimensions of content above the emoji picker list
935935
const dimensions = isRenderingShortcutRow ? CONST.EMOJI_PICKER_TEXT_INPUT_SIZES + CONST.CATEGORY_SHORTCUT_BAR_HEIGHT : CONST.EMOJI_PICKER_TEXT_INPUT_SIZES;
936+
const maxHeight = windowHeight - dimensions;
936937
return {
937938
...style,
938-
maxHeight: windowHeight - dimensions,
939+
maxHeight,
940+
/**
941+
* On native platforms, `maxHeight` doesn't work as expected, so we manually
942+
* enforce the height by returning the smaller of the element's height or the
943+
* `maxHeight`, ensuring it doesn't exceed the maximum allowed.
944+
*/
945+
height: Math.min(style.height, maxHeight),
939946
};
940947
}
941948
return style;

0 commit comments

Comments
 (0)