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/post_view/components/post.jsx | 4 +- .../post_view/components/post_header.jsx | 4 +- .../components/post_view/components/post_info.jsx | 56 ++++++++++++---------- .../components/post_view/components/post_list.jsx | 5 ++ 4 files changed, 41 insertions(+), 28 deletions(-) (limited to 'webapp/components/post_view') diff --git a/webapp/components/post_view/components/post.jsx b/webapp/components/post_view/components/post.jsx index c1b932774..b9823396d 100644 --- a/webapp/components/post_view/components/post.jsx +++ b/webapp/components/post_view/components/post.jsx @@ -38,7 +38,8 @@ export default class Post extends Component { isFlagged: PropTypes.bool, status: PropTypes.string, isBusy: PropTypes.bool, - childComponentDidUpdateFunction: PropTypes.func + childComponentDidUpdateFunction: PropTypes.func, + getPostList: PropTypes.func.isRequired }; constructor(props) { @@ -308,6 +309,7 @@ export default class Post extends Component { isFlagged={this.props.isFlagged} status={this.props.status} isBusy={this.props.isBusy} + getPostList={this.props.getPostList} /> @@ -119,5 +120,6 @@ PostHeader.propTypes = { useMilitaryTime: PropTypes.bool.isRequired, isFlagged: PropTypes.bool.isRequired, status: PropTypes.string, - isBusy: PropTypes.bool + isBusy: PropTypes.bool, + getPostList: PropTypes.func.isRequired }; diff --git a/webapp/components/post_view/components/post_info.jsx b/webapp/components/post_view/components/post_info.jsx index 39a0b1fec..45c716ad0 100644 --- a/webapp/components/post_view/components/post_info.jsx +++ b/webapp/components/post_view/components/post_info.jsx @@ -2,7 +2,6 @@ // See License.txt for license information. import $ from 'jquery'; -import ReactDOM from 'react-dom'; import PostTime from './post_time.jsx'; import PostFlagIcon from 'components/common/post_flag_icon.jsx'; @@ -15,8 +14,7 @@ import * as Utils from 'utils/utils.jsx'; import * as PostUtils from 'utils/post_utils.jsx'; import Constants from 'utils/constants.jsx'; import DelayedAction from 'utils/delayed_action.jsx'; -import {Overlay} from 'react-bootstrap'; -import EmojiPicker from 'components/emoji_picker/emoji_picker.jsx'; +import EmojiPickerOverlay from 'components/emoji_picker/emoji_picker_overlay.jsx'; import ChannelStore from 'stores/channel_store.jsx'; import PropTypes from 'prop-types'; @@ -36,7 +34,6 @@ export default class PostInfo 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.canEdit = false; this.canDelete = false; @@ -280,8 +277,16 @@ export default class PostInfo extends React.Component { GlobalActions.showGetPostLinkModal(this.props.post); } - emojiPickerClick() { - this.setState({showEmojiPicker: !this.state.showEmojiPicker}); + toggleEmojiPicker = () => { + const showEmojiPicker = !this.state.showEmojiPicker; + + this.setState({showEmojiPicker}); + this.props.handleDropdownOpened(showEmojiPicker); + } + + hideEmojiPicker = () => { + this.setState({showEmojiPicker: false}); + this.props.handleDropdownOpened(false); } removePost() { @@ -328,6 +333,10 @@ export default class PostInfo extends React.Component { PostActions.addReaction(this.props.post.channel_id, this.props.post.id, emojiName); } + getDotMenu = () => { + return this.refs.dotMenu; + } + render() { var post = this.props.post; @@ -359,30 +368,21 @@ export default class PostInfo extends React.Component { if (Utils.isFeatureEnabled(Constants.PRE_RELEASE_FEATURES.EMOJI_PICKER_PREVIEW)) { react = ( - this.setState({showEmojiPicker: false})} - target={() => ReactDOM.findDOMNode(this.refs['reactIcon_' + post.id])} - animation={false} - > - - + container={this.props.getPostList} + target={this.getDotMenu} + onHide={this.hideEmojiPicker} + onEmojiClick={this.reactEmojiClick} + /> + onClick={this.toggleEmojiPicker} + > + - ); } } @@ -399,7 +399,10 @@ export default class PostInfo extends React.Component { if (dropdown) { options = ( -
+
); @@ -562,6 +563,10 @@ export default class PostList extends React.Component { this.checkAndUpdateScrolling(); } + getPostList = () => { + return this.refs.postlist; + } + render() { // Create intro message or top loadmore link let moreMessagesTop; -- cgit v1.2.3-1-g7c22