From 40efd8367a85e3333e9b7cc45c390259d412088c Mon Sep 17 00:00:00 2001 From: Harrison Healey Date: Tue, 13 Jun 2017 14:35:45 -0400 Subject: PLT-6127/PLT-6135/PLT-6137 Added EmojiPickerOverlay component to better position emoji picker (#6352) * Cleaned up emoji picker CSS * Fixed border of emoji picker when reacting to comments in the RHS * PLT-6135 Made EmojiPicker automatically position itself above/below the [...] menu * PLT-6135 Changed post textbox emoji picker to use a RootCloseWrapper * PLT-6135 Changed comment textbox emoji picker to use a RootCloseWrapper * PLT-6135 Changed RHS post components to use EmojiPickerOverlay * Removed react-outside-event package * Fixed merge conflict * Fixed emoji picker position on posts in RHS * Removed unused CSS classes * Fixed not being able to react to posts with emoji picker --- webapp/components/rhs_root_post.jsx | 57 ++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 32 deletions(-) (limited to 'webapp/components/rhs_root_post.jsx') diff --git a/webapp/components/rhs_root_post.jsx b/webapp/components/rhs_root_post.jsx index c00022e9e..e77fb7992 100644 --- a/webapp/components/rhs_root_post.jsx +++ b/webapp/components/rhs_root_post.jsx @@ -20,12 +20,10 @@ import {flagPost, unflagPost, pinPost, unpinPost, addReaction} from 'actions/pos import * as Utils from 'utils/utils.jsx'; import * as PostUtils from 'utils/post_utils.jsx'; -import EmojiPicker from 'components/emoji_picker/emoji_picker.jsx'; -import ReactDOM from 'react-dom'; +import EmojiPickerOverlay from 'components/emoji_picker/emoji_picker_overlay.jsx'; import Constants from 'utils/constants.jsx'; import DelayedAction from 'utils/delayed_action.jsx'; -import {Overlay} from 'react-bootstrap'; import {FormattedMessage} from 'react-intl'; @@ -44,7 +42,6 @@ export default class RhsRootPost extends React.Component { this.pinPost = this.pinPost.bind(this); this.unpinPost = this.unpinPost.bind(this); this.reactEmojiClick = this.reactEmojiClick.bind(this); - this.emojiPickerClick = this.emojiPickerClick.bind(this); this.handleDropdownOpened = this.handleDropdownOpened.bind(this); this.canEdit = false; @@ -55,7 +52,7 @@ export default class RhsRootPost extends React.Component { currentTeamDisplayName: TeamStore.getCurrent().name, width: '', height: '', - showRHSEmojiPicker: false, + showEmojiPicker: false, testStateObj: true, dropdownOpened: false }; @@ -119,7 +116,7 @@ export default class RhsRootPost extends React.Component { return true; } - if (this.state.showRHSEmojiPicker !== nextState.showRHSEmojiPicker) { + if (this.state.showEmojiPicker !== nextState.showEmojiPicker) { return true; } @@ -175,12 +172,17 @@ export default class RhsRootPost extends React.Component { unpinPost(this.props.post.channel_id, this.props.post.id); } - emojiPickerClick() { - this.setState({showRHSEmojiPicker: !this.state.showRHSEmojiPicker}); + toggleEmojiPicker = () => { + const showEmojiPicker = !this.state.showEmojiPicker; + + this.setState({ + showEmojiPicker, + dropdownOpened: showEmojiPicker + }); } reactEmojiClick(emoji) { - this.setState({showRHSEmojiPicker: false}); + this.setState({showEmojiPicker: false}); const emojiName = emoji.name || emoji.aliases[0]; addReaction(this.props.post.channel_id, this.props.post.id, emojiName); } @@ -250,38 +252,26 @@ export default class RhsRootPost extends React.Component { } let react; - let reactOverlay; - if (!isEphemeral && !isPending && !isSystemMessage && Utils.isFeatureEnabled(Constants.PRE_RELEASE_FEATURES.EMOJI_PICKER_PREVIEW)) { react = ( + this.refs.dotMenu} + container={this.props.getPostList} + onEmojiClick={this.reactEmojiClick} + /> ); - reactOverlay = ( - this.setState({showRHSEmojiPicker: false})} - target={() => ReactDOM.findDOMNode(this.refs.rhs_root_reacticon)} - animation={false} - > - - - ); } var dropdownContents = []; @@ -590,8 +580,10 @@ export default class RhsRootPost extends React.Component { isFlagged={this.props.isFlagged} /> -
- {reactOverlay} +
{rootOptions} {react}
@@ -628,5 +620,6 @@ RhsRootPost.propTypes = { isFlagged: PropTypes.bool, status: PropTypes.string, previewCollapsed: PropTypes.string, - isBusy: PropTypes.bool + isBusy: PropTypes.bool, + getPostList: PropTypes.func.isRequired }; -- cgit v1.2.3-1-g7c22