Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: emoji picker hides on resize window #28688

Merged
merged 3 commits into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
13 changes: 10 additions & 3 deletions src/components/Popover/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, {useRef} from 'react';
import {createPortal} from 'react-dom';
import {propTypes, defaultProps} from './popoverPropTypes';
import CONST from '../../CONST';
Expand All @@ -12,6 +12,7 @@ import PopoverWithoutOverlay from '../PopoverWithoutOverlay';
*/
function Popover(props) {
const {isVisible, onClose, isSmallScreenWidth, fullscreen, animationInTiming, onLayout, animationOutTiming, disableAnimation, withoutOverlay, anchorPosition} = props;
const withoutOverlayRef = useRef(null);

// Not adding this inside the PopoverProvider
// because this is an issue on smaller screens as well.
Expand Down Expand Up @@ -46,8 +47,14 @@ function Popover(props) {
}

if (withoutOverlay && !isSmallScreenWidth) {
// eslint-disable-next-line react/jsx-props-no-spreading
return createPortal(<PopoverWithoutOverlay {...props} />, document.body);
return createPortal(
<PopoverWithoutOverlay
// eslint-disable-next-line react/jsx-props-no-spreading
{...props}
withoutOverlayRef={withoutOverlayRef}
/>,
document.body,
);
}

return (
Expand Down
4 changes: 4 additions & 0 deletions src/components/Popover/popoverPropTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ const propTypes = {

/** Whether disable the animations */
disableAnimation: PropTypes.bool,

/** The ref of the popover */
withoutOverlayRef: refPropTypes,
};

const defaultProps = {
Expand All @@ -36,6 +39,7 @@ const defaultProps = {
anchorPosition: {},
anchorRef: () => {},
disableAnimation: true,
withoutOverlayRef: () => {},
};

export {propTypes, defaultProps};
5 changes: 2 additions & 3 deletions src/components/PopoverWithoutOverlay/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import getModalStyles from '../../styles/getModalStyles';
import withWindowDimensions from '../withWindowDimensions';

function Popover(props) {
const ref = React.useRef(null);
const {onOpen, close} = React.useContext(PopoverContext);
const {modalStyle, modalContainerStyle, shouldAddTopSafeAreaMargin, shouldAddBottomSafeAreaMargin, shouldAddTopSafeAreaPadding, shouldAddBottomSafeAreaPadding} = getModalStyles(
'popover',
Expand All @@ -28,7 +27,7 @@ function Popover(props) {
if (props.isVisible) {
props.onModalShow();
onOpen({
ref,
ref: props.withoutOverlayRef,
close: props.onClose,
anchorRef: props.anchorRef,
});
Expand All @@ -51,7 +50,7 @@ function Popover(props) {
return (
<View
style={[modalStyle, {zIndex: 1}]}
ref={ref}
ref={props.withoutOverlayRef}
>
<SafeAreaInsetsContext.Consumer>
{(insets) => {
Expand Down
Loading