Skip to content

Commit

Permalink
Merge pull request #53806 from huult/53218-emoji-picker-no-dismiss-space
Browse files Browse the repository at this point in the history
add dismiss space for emoji picker when searching
  • Loading branch information
marcaaron authored Dec 11, 2024
2 parents 567bd21 + 9b93483 commit b6414b3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
12 changes: 8 additions & 4 deletions src/components/EmojiPicker/EmojiPickerMenu/useEmojiPickerMenu.ts
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);

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

0 comments on commit b6414b3

Please sign in to comment.