mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
fix JS error and incorrect comment thread for SHIFT+UP (#6574)
This commit is contained in:
committed by
Harrison Healey
parent
b53ca57bad
commit
b0f32e3c19
@@ -21,7 +21,7 @@ export default function CommentIcon(props) {
|
||||
iconStyle = iconStyle + ' ' + props.searchStyle;
|
||||
}
|
||||
|
||||
let commentIconId = props.idPrefix;
|
||||
let commentIconId = props.channelId + props.idPrefix;
|
||||
if (props.idCount > -1) {
|
||||
commentIconId += props.idCount;
|
||||
}
|
||||
@@ -47,11 +47,13 @@ CommentIcon.propTypes = {
|
||||
idCount: PropTypes.number,
|
||||
handleCommentClick: PropTypes.func.isRequired,
|
||||
searchStyle: PropTypes.string,
|
||||
commentCount: PropTypes.number
|
||||
commentCount: PropTypes.number,
|
||||
channelId: PropTypes.string
|
||||
};
|
||||
|
||||
CommentIcon.defaultProps = {
|
||||
idCount: -1,
|
||||
searchStyle: '',
|
||||
commentCount: 0
|
||||
commentCount: 0,
|
||||
channelId: ''
|
||||
};
|
||||
@@ -504,11 +504,12 @@ export default class CreatePost extends React.Component {
|
||||
return;
|
||||
}
|
||||
|
||||
const lastPostEl = document.getElementById(this.state.channelId + 'commentIcon0');
|
||||
|
||||
if (!e.ctrlKey && !e.metaKey && !e.altKey && !e.shiftKey && e.keyCode === KeyCodes.UP && this.state.message === '') {
|
||||
e.preventDefault();
|
||||
|
||||
const channelId = ChannelStore.getCurrentId();
|
||||
const lastPost = PostStore.getCurrentUsersLatestPost(channelId);
|
||||
const lastPost = PostStore.getCurrentUsersLatestPost(this.state.channelId);
|
||||
if (!lastPost) {
|
||||
return;
|
||||
}
|
||||
@@ -529,15 +530,15 @@ export default class CreatePost extends React.Component {
|
||||
channelId: lastPost.channel_id,
|
||||
comments: PostStore.getCommentCount(lastPost)
|
||||
});
|
||||
} else if (!e.ctrlKey && !e.metaKey && !e.altKey && e.shiftKey && e.keyCode === KeyCodes.UP && this.state.message === '') {
|
||||
} else if (!e.ctrlKey && !e.metaKey && !e.altKey && e.shiftKey && e.keyCode === KeyCodes.UP && this.state.message === '' && lastPostEl) {
|
||||
e.preventDefault();
|
||||
if (document.createEvent) {
|
||||
var evt = document.createEvent('MouseEvents');
|
||||
const evt = document.createEvent('MouseEvents');
|
||||
evt.initMouseEvent('click', true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
|
||||
document.getElementById('commentIcon0').dispatchEvent(evt);
|
||||
lastPostEl.dispatchEvent(evt);
|
||||
} else if (document.createEventObject) {
|
||||
var evObj = document.createEventObject();
|
||||
document.getElementById('commentIcon0').fireEvent('onclick', evObj);
|
||||
const evObj = document.createEventObject();
|
||||
lastPostEl.fireEvent('onclick', evObj);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ 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 ChannelStore from 'stores/channel_store.jsx';
|
||||
|
||||
import PropTypes from 'prop-types';
|
||||
|
||||
@@ -351,6 +352,7 @@ export default class PostInfo extends React.Component {
|
||||
idCount={idCount}
|
||||
handleCommentClick={this.props.handleCommentClick}
|
||||
commentCount={this.props.commentCount}
|
||||
channelId={ChannelStore.getCurrentId()}
|
||||
/>
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user