Skip to content

Commit

Permalink
add isSmallScreenWidth
Browse files Browse the repository at this point in the history
  • Loading branch information
tienifr committed Oct 23, 2023
1 parent 802bb8c commit 9f3ea4d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
8 changes: 3 additions & 5 deletions src/components/EmojiPicker/EmojiPicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import EmojiPickerMenu from './EmojiPickerMenu';
import CONST from '../../CONST';
import styles from '../../styles/styles';
import PopoverWithMeasuredContent from '../PopoverWithMeasuredContent';
import {windowDimensionsPropTypes} from '../withWindowDimensions';
import withViewportOffsetTop from '../withViewportOffsetTop';
import * as StyleUtils from '../../styles/StyleUtils';
import calculateAnchorPosition from '../../libs/calculateAnchorPosition';
Expand All @@ -18,7 +17,6 @@ const DEFAULT_ANCHOR_ORIGIN = {
};

const propTypes = {
...windowDimensionsPropTypes,
viewportOffsetTop: PropTypes.number.isRequired,
};

Expand All @@ -34,7 +32,7 @@ const EmojiPicker = forwardRef((props, ref) => {
const onModalHide = useRef(() => {});
const onEmojiSelected = useRef(() => {});
const emojiSearchInput = useRef();
const {windowHeight} = useWindowDimensions();
const {isSmallScreenWidth, windowHeight} = useWindowDimensions();

/**
* Show the emoji picker menu.
Expand Down Expand Up @@ -126,7 +124,7 @@ const EmojiPicker = forwardRef((props, ref) => {
const emojiPopoverDimensionListener = Dimensions.addEventListener('change', () => {
if (!emojiPopoverAnchor.current) {
// In small screen width, the window size change might be due to keyboard open/hide, we should avoid hide EmojiPicker in those cases
if (isEmojiPickerVisible && !props.isSmallScreenWidth) {
if (isEmojiPickerVisible && !isSmallScreenWidth) {
hideEmojiPicker();
}
return;
Expand All @@ -138,7 +136,7 @@ const EmojiPicker = forwardRef((props, ref) => {
return () => {
emojiPopoverDimensionListener.remove();
};
}, [isEmojiPickerVisible, props.isSmallScreenWidth, emojiPopoverAnchorOrigin]);
}, [isEmojiPickerVisible, isSmallScreenWidth, emojiPopoverAnchorOrigin]);

// There is no way to disable animations, and they are really laggy, because there are so many
// emojis. The best alternative is to set it to 1ms so it just "pops" in and out
Expand Down
8 changes: 2 additions & 6 deletions src/components/EmojiPicker/EmojiPickerMenu/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import * as StyleUtils from '../../../styles/StyleUtils';
import emojiAssets from '../../../../assets/emojis';
import EmojiPickerMenuItem from '../EmojiPickerMenuItem';
import Text from '../../Text';
import {windowDimensionsPropTypes} from '../../withWindowDimensions';
import withLocalize, {withLocalizePropTypes} from '../../withLocalize';
import compose from '../../../libs/compose';
import getOperatingSystem from '../../../libs/getOperatingSystem';
Expand All @@ -38,9 +37,6 @@ const propTypes = {
// eslint-disable-next-line react/forbid-prop-types
frequentlyUsedEmojis: PropTypes.arrayOf(PropTypes.object),

/** Props related to the dimensions of the window */
...windowDimensionsPropTypes,

...withLocalizePropTypes,
};

Expand All @@ -53,9 +49,9 @@ const defaultProps = {
const throttleTime = Browser.isMobile() ? 200 : 50;

function EmojiPickerMenu(props) {
const {forwardedRef, frequentlyUsedEmojis, preferredSkinTone, onEmojiSelected, preferredLocale, isSmallScreenWidth, translate} = props;
const {forwardedRef, frequentlyUsedEmojis, preferredSkinTone, onEmojiSelected, preferredLocale, translate} = props;

const {windowHeight} = useWindowDimensions();
const {isSmallScreenWidth, windowHeight} = useWindowDimensions();

// Ref for the emoji search input
const searchInputRef = useRef(null);
Expand Down

0 comments on commit 9f3ea4d

Please sign in to comment.