From 81a893b556bbd4e5a73dd41b3dad92915cb06119 Mon Sep 17 00:00:00 2001 From: Saturnino Abril Date: Thu, 6 Jul 2017 04:21:04 +0800 Subject: fix position of emoji picker (#6837) --- webapp/components/channel_view.jsx | 15 +++- webapp/components/create_comment.jsx | 75 ++++++++++++------- webapp/components/create_post.jsx | 83 ++++++++++++++-------- webapp/components/emoji_picker/emoji_picker.jsx | 13 +++- .../emoji_picker/emoji_picker_overlay.jsx | 10 ++- webapp/components/file_upload.jsx | 24 +------ .../components/post_view/post_info/post_info.jsx | 1 + webapp/components/rhs_comment.jsx | 1 + webapp/components/rhs_root_post.jsx | 1 + webapp/components/rhs_thread/rhs_thread.jsx | 10 ++- 10 files changed, 153 insertions(+), 80 deletions(-) diff --git a/webapp/components/channel_view.jsx b/webapp/components/channel_view.jsx index 6c2157ffd..4a5ac8969 100644 --- a/webapp/components/channel_view.jsx +++ b/webapp/components/channel_view.jsx @@ -31,18 +31,22 @@ export default class ChannelView extends React.Component { this.state = this.getStateFromStores(props); } + getStateFromStores() { return { channelId: ChannelStore.getCurrentId(), tutorialStep: PreferenceStore.getInt(Preferences.TUTORIAL_STEP, UserStore.getCurrentId(), 999) }; } + isStateValid() { return this.state.channelId !== ''; } + updateState() { this.setState(this.getStateFromStores(this.props)); } + componentDidMount() { ChannelStore.addChangeListener(this.updateState); @@ -53,14 +57,17 @@ export default class ChannelView extends React.Component { $('body').addClass('browser--ie'); } } + componentWillUnmount() { ChannelStore.removeChangeListener(this.updateState); $('body').removeClass('app__body'); } + componentWillReceiveProps(nextProps) { this.setState(this.getStateFromStores(nextProps)); } + shouldComponentUpdate(nextProps, nextState) { if (!Utils.areObjectsEqual(nextProps.params, this.props.params)) { return true; @@ -72,6 +79,11 @@ export default class ChannelView extends React.Component { return false; } + + getChannelView = () => { + return this.refs.channelView; + } + render() { if (this.state.tutorialStep <= TutorialSteps.INTRO_SCREENS) { return (); @@ -79,6 +91,7 @@ export default class ChannelView extends React.Component { return (
@@ -93,7 +106,7 @@ export default class ChannelView extends React.Component { className='post-create__container' id='post-create' > - +
); diff --git a/webapp/components/create_comment.jsx b/webapp/components/create_comment.jsx index 2ddc828cc..1a2bbeeae 100644 --- a/webapp/components/create_comment.jsx +++ b/webapp/components/create_comment.jsx @@ -15,7 +15,7 @@ import Textbox from './textbox.jsx'; import MsgTyping from './msg_typing.jsx'; import FileUpload from './file_upload.jsx'; import FilePreview from './file_preview.jsx'; -import EmojiPicker from './emoji_picker/emoji_picker.jsx'; +import EmojiPickerOverlay from 'components/emoji_picker/emoji_picker_overlay.jsx'; import * as Utils from 'utils/utils.jsx'; import * as UserAgent from 'utils/user_agent.jsx'; import * as GlobalActions from 'actions/global_actions.jsx'; @@ -24,7 +24,6 @@ import * as PostActions from 'actions/post_actions.jsx'; import Constants from 'utils/constants.jsx'; import {FormattedMessage} from 'react-intl'; -import {RootCloseWrapper} from 'react-overlays'; import {browserHistory} from 'react-router/es6'; const ActionTypes = Constants.ActionTypes; @@ -54,12 +53,15 @@ export default class CreateComment extends React.Component { this.removePreview = this.removePreview.bind(this); this.getFileCount = this.getFileCount.bind(this); this.getFileUploadTarget = this.getFileUploadTarget.bind(this); + this.getCreateCommentControls = this.getCreateCommentControls.bind(this); this.onPreferenceChange = this.onPreferenceChange.bind(this); this.focusTextbox = this.focusTextbox.bind(this); this.showPostDeletedModal = this.showPostDeletedModal.bind(this); this.hidePostDeletedModal = this.hidePostDeletedModal.bind(this); this.handlePostError = this.handlePostError.bind(this); this.handleEmojiClick = this.handleEmojiClick.bind(this); + this.toggleEmojiPicker = this.toggleEmojiPicker.bind(this); + this.hideEmojiPicker = this.hideEmojiPicker.bind(this); PostStore.clearCommentDraftUploads(); MessageHistoryStore.resetHistoryIndex('comment'); @@ -81,10 +83,14 @@ export default class CreateComment extends React.Component { this.lastBlurAt = 0; } - toggleEmojiPicker = () => { + toggleEmojiPicker() { this.setState({showEmojiPicker: !this.state.showEmojiPicker}); } + hideEmojiPicker() { + this.setState({showEmojiPicker: false}); + } + handleEmojiClick(emoji) { const emojiAlias = emoji.name || emoji.aliases[0]; @@ -470,6 +476,10 @@ export default class CreateComment extends React.Component { return this.refs.textbox; } + getCreateCommentControls() { + return this.refs.createCommentControls; + } + focusTextbox(keepFocus = false) { if (keepFocus || !Utils.isMobile()) { this.refs.textbox.focus(); @@ -548,15 +558,38 @@ export default class CreateComment extends React.Component { addButtonClass += ' disabled'; } + const fileUpload = ( + + ); + let emojiPicker = null; - if (this.state.showEmojiPicker) { + if (Utils.isFeatureEnabled(Constants.PRE_RELEASE_FEATURES.EMOJI_PICKER_PREVIEW)) { emojiPicker = ( - - + - + + ); } @@ -582,22 +615,13 @@ export default class CreateComment extends React.Component { id='reply_textbox' ref='textbox' /> - - - {emojiPicker} + + {fileUpload} + {emojiPicker} + { + this.setState({showEmojiPicker: false}); + } + doSubmit(e) { if (e) { e.preventDefault(); @@ -500,6 +505,10 @@ export default class CreatePost extends React.Component { return this.refs.textbox; } + getCreatePostControls() { + return this.refs.createPostControls; + } + handleKeyDown(e) { if (this.state.ctrlSend && e.keyCode === KeyCodes.ENTER && e.ctrlKey === true) { this.postMsgKeyPress(e); @@ -693,23 +702,46 @@ export default class CreatePost extends React.Component { sendButtonClass += ' disabled'; } + let attachmentsDisabled = ''; + if (global.window.mm_config.EnableFileAttachments === 'false') { + attachmentsDisabled = ' post-create--attachment-disabled'; + } + + const fileUpload = ( + + ); + let emojiPicker = null; - if (this.state.showEmojiPicker) { + if (Utils.isFeatureEnabled(Constants.PRE_RELEASE_FEATURES.EMOJI_PICKER_PREVIEW)) { emojiPicker = ( - - + + - + ); } - let attachmentsDisabled = ''; - if (global.window.mm_config.EnableFileAttachments === 'false') { - attachmentsDisabled = ' post-create--attachment-disabled'; - } - return (
- - - {emojiPicker} + + {fileUpload} + {emojiPicker} + - + ); } diff --git a/webapp/components/file_upload.jsx b/webapp/components/file_upload.jsx index 17bb50a2b..0b32ab66e 100644 --- a/webapp/components/file_upload.jsx +++ b/webapp/components/file_upload.jsx @@ -51,7 +51,6 @@ class FileUpload extends React.Component { this.pasteUpload = this.pasteUpload.bind(this); this.keyUpload = this.keyUpload.bind(this); this.handleMaxUploadReached = this.handleMaxUploadReached.bind(this); - this.emojiClick = this.emojiClick.bind(this); this.state = { requests: {} @@ -230,10 +229,6 @@ class FileUpload extends React.Component { target.off('dragenter dragleave dragover drop dragster:enter dragster:leave dragster:over dragster:drop'); } - emojiClick() { - this.props.onEmojiClick(); - } - pasteUpload(e) { const {formatMessage} = this.props.intl; @@ -377,19 +372,8 @@ class FileUpload extends React.Component { } const channelId = this.props.channelId || ChannelStore.getCurrentId(); - const uploadsRemaining = Constants.MAX_UPLOAD_FILES - this.props.getFileCount(channelId); - let emojiSpan; - if (this.props.emojiEnabled) { - emojiSpan = ( - - ); - } - let fileDiv; if (global.window.mm_config.EnableFileAttachments === 'true') { fileDiv = ( @@ -413,10 +397,9 @@ class FileUpload extends React.Component { return ( {fileDiv} - {emojiSpan} ); } @@ -433,10 +416,7 @@ FileUpload.propTypes = { onFileUploadChange: PropTypes.func, onTextDrop: PropTypes.func, channelId: PropTypes.string, - postType: PropTypes.string, - onEmojiClick: PropTypes.func, - navBarName: PropTypes.string, - emojiEnabled: PropTypes.bool + postType: PropTypes.string }; export default injectIntl(FileUpload, {withRef: true}); diff --git a/webapp/components/post_view/post_info/post_info.jsx b/webapp/components/post_view/post_info/post_info.jsx index c07a58bc7..36e0ea431 100644 --- a/webapp/components/post_view/post_info/post_info.jsx +++ b/webapp/components/post_view/post_info/post_info.jsx @@ -158,6 +158,7 @@ export default class PostInfo extends React.PureComponent { target={this.getDotMenu} onHide={this.hideEmojiPicker} onEmojiClick={this.reactEmojiClick} + rightOffset={7} /> this.refs.dotMenu} container={this.props.getPostList} onEmojiClick={this.reactEmojiClick} + rightOffset={15} /> this.refs.dotMenu} container={this.props.getPostList} onEmojiClick={this.reactEmojiClick} + rightOffset={15} /> { + return this.refs.sidebarbody; + } + render() { if (this.props.posts == null || this.props.selected == null) { return ( @@ -403,7 +407,10 @@ export default class RhsThread extends React.Component { } return ( -
+
0 ? postsArray[postsLength - 1].id : selected.id} + getSidebarBody={this.getSidebarBody} />
-- cgit v1.2.3-1-g7c22