Skip to content

Commit

Permalink
Merge pull request #45449 from bernhardoj/fix/44986-emoji-picker-clos…
Browse files Browse the repository at this point in the history
…ed-immediately-when-open-it-from-context-menu

Fix emoji picker closes when open it from report context menu add reaction button
  • Loading branch information
aldo-expensify authored Jul 16, 2024
2 parents e3bf615 + 0231ae3 commit 6b72c26
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions src/components/EmojiPicker/EmojiPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import useWindowDimensions from '@hooks/useWindowDimensions';
import type {AnchorOrigin, EmojiPickerRef, EmojiPopoverAnchor, OnEmojiSelected, OnModalHideValue, OnWillShowPicker} from '@libs/actions/EmojiPickerAction';
import * as Browser from '@libs/Browser';
import calculateAnchorPosition from '@libs/calculateAnchorPosition';
import * as Modal from '@userActions/Modal';
import CONST from '@src/CONST';
import EmojiPickerMenu from './EmojiPickerMenu';

Expand Down Expand Up @@ -87,19 +88,23 @@ function EmojiPicker({viewportOffsetTop}: EmojiPickerProps, ref: ForwardedRef<Em

const anchorOriginValue = anchorOrigin ?? DEFAULT_ANCHOR_ORIGIN;

// It's possible that the anchor is inside an active modal (e.g., add emoji reaction in report context menu).
// So, we need to get the anchor position first before closing the active modal which will also destroy the anchor.
calculateAnchorPosition(emojiPopoverAnchor?.current, anchorOriginValue).then((value) => {
onWillShow?.();
setIsEmojiPickerVisible(true);
setEmojiPopoverAnchorPosition({
horizontal: value.horizontal,
vertical: value.vertical,
Modal.close(() => {
onWillShow?.();
setIsEmojiPickerVisible(true);
setEmojiPopoverAnchorPosition({
horizontal: value.horizontal,
vertical: value.vertical,
});
emojiAnchorDimension.current = {
width: value.width,
height: value.height,
};
setEmojiPopoverAnchorOrigin(anchorOriginValue);
setActiveID(id);
});
emojiAnchorDimension.current = {
width: value.width,
height: value.height,
};
setEmojiPopoverAnchorOrigin(anchorOriginValue);
setActiveID(id);
});
};

Expand Down

0 comments on commit 6b72c26

Please sign in to comment.