@@ -5,6 +5,11 @@ import EmojiPickerMenu from './EmojiPickerMenu';
55import CONST from '../../CONST' ;
66import PopoverWithMeasuredContent from '../PopoverWithMeasuredContent' ;
77
8+ const DEFAULT_ANCHOR_ORIGIN = {
9+ horizontal : CONST . MODAL . ANCHOR_ORIGIN_HORIZONTAL . RIGHT ,
10+ vertical : CONST . MODAL . ANCHOR_ORIGIN_VERTICAL . BOTTOM ,
11+ } ;
12+
813class EmojiPicker extends React . Component {
914 constructor ( props ) {
1015 super ( props ) ;
@@ -27,6 +32,8 @@ class EmojiPicker extends React.Component {
2732 horizontal : 0 ,
2833 vertical : 0 ,
2934 } ,
35+
36+ emojiPopoverAnchorOrigin : DEFAULT_ANCHOR_ORIGIN ,
3037 } ;
3138 }
3239
@@ -54,8 +61,9 @@ class EmojiPicker extends React.Component {
5461 * Callback for the emoji picker to add whatever emoji is chosen into the main input
5562 *
5663 * @param {String } emoji
64+ * @param {Object } emojiObject
5765 */
58- selectEmoji ( emoji ) {
66+ selectEmoji ( emoji , emojiObject ) {
5967 // Prevent fast click / multiple emoji selection;
6068 // The first click will hide the emoji picker by calling the hideEmojiPicker() function
6169 // and in that function the emojiPopoverAnchor prop to will be set to null (synchronously)
@@ -66,7 +74,7 @@ class EmojiPicker extends React.Component {
6674
6775 this . hideEmojiPicker ( ) ;
6876 if ( _ . isFunction ( this . onEmojiSelected ) ) {
69- this . onEmojiSelected ( emoji ) ;
77+ this . onEmojiSelected ( emoji , emojiObject ) ;
7078 }
7179 }
7280
@@ -81,8 +89,10 @@ class EmojiPicker extends React.Component {
8189 * @param {Function } [onModalHide=() => {}] - Run a callback when Modal hides.
8290 * @param {Function } [onEmojiSelected=() => {}] - Run a callback when Emoji selected.
8391 * @param {Element } emojiPopoverAnchor - Element to which Popover is anchored
92+ * @param {Object } [anchorOrigin=DEFAULT_ANCHOR_ORIGIN] - Anchor origin for Popover
93+ * @param {Function } [onWillShow=() => {}] - Run a callback when Popover will show
8494 */
85- showEmojiPicker ( onModalHide , onEmojiSelected , emojiPopoverAnchor ) {
95+ showEmojiPicker ( onModalHide , onEmojiSelected , emojiPopoverAnchor , anchorOrigin , onWillShow = ( ) => { } ) {
8696 this . onModalHide = onModalHide ;
8797 this . onEmojiSelected = onEmojiSelected ;
8898 this . emojiPopoverAnchor = emojiPopoverAnchor ;
@@ -93,7 +103,8 @@ class EmojiPicker extends React.Component {
93103 }
94104
95105 this . measureEmojiPopoverAnchorPosition ( ) . then ( ( emojiPopoverAnchorPosition ) => {
96- this . setState ( { isEmojiPickerVisible : true , emojiPopoverAnchorPosition} ) ;
106+ onWillShow ( ) ;
107+ this . setState ( { isEmojiPickerVisible : true , emojiPopoverAnchorPosition, emojiPopoverAnchorOrigin : anchorOrigin || DEFAULT_ANCHOR_ORIGIN } ) ;
97108 } ) ;
98109 }
99110
@@ -157,10 +168,7 @@ class EmojiPicker extends React.Component {
157168 width : CONST . EMOJI_PICKER_SIZE . WIDTH ,
158169 height : CONST . EMOJI_PICKER_SIZE . HEIGHT ,
159170 } }
160- anchorOrigin = { {
161- horizontal : CONST . MODAL . ANCHOR_ORIGIN_HORIZONTAL . RIGHT ,
162- vertical : CONST . MODAL . ANCHOR_ORIGIN_VERTICAL . BOTTOM ,
163- } }
171+ anchorOrigin = { this . state . emojiPopoverAnchorOrigin }
164172 measureContent = { this . measureContent }
165173 >
166174 < EmojiPickerMenu
0 commit comments