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;
|
iconStyle = iconStyle + ' ' + props.searchStyle;
|
||||||
}
|
}
|
||||||
|
|
||||||
let commentIconId = props.idPrefix;
|
let commentIconId = props.channelId + props.idPrefix;
|
||||||
if (props.idCount > -1) {
|
if (props.idCount > -1) {
|
||||||
commentIconId += props.idCount;
|
commentIconId += props.idCount;
|
||||||
}
|
}
|
||||||
@@ -47,11 +47,13 @@ CommentIcon.propTypes = {
|
|||||||
idCount: PropTypes.number,
|
idCount: PropTypes.number,
|
||||||
handleCommentClick: PropTypes.func.isRequired,
|
handleCommentClick: PropTypes.func.isRequired,
|
||||||
searchStyle: PropTypes.string,
|
searchStyle: PropTypes.string,
|
||||||
commentCount: PropTypes.number
|
commentCount: PropTypes.number,
|
||||||
|
channelId: PropTypes.string
|
||||||
};
|
};
|
||||||
|
|
||||||
CommentIcon.defaultProps = {
|
CommentIcon.defaultProps = {
|
||||||
idCount: -1,
|
idCount: -1,
|
||||||
searchStyle: '',
|
searchStyle: '',
|
||||||
commentCount: 0
|
commentCount: 0,
|
||||||
|
channelId: ''
|
||||||
};
|
};
|
||||||
@@ -504,11 +504,12 @@ export default class CreatePost extends React.Component {
|
|||||||
return;
|
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 === '') {
|
if (!e.ctrlKey && !e.metaKey && !e.altKey && !e.shiftKey && e.keyCode === KeyCodes.UP && this.state.message === '') {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
const channelId = ChannelStore.getCurrentId();
|
const lastPost = PostStore.getCurrentUsersLatestPost(this.state.channelId);
|
||||||
const lastPost = PostStore.getCurrentUsersLatestPost(channelId);
|
|
||||||
if (!lastPost) {
|
if (!lastPost) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -529,15 +530,15 @@ export default class CreatePost extends React.Component {
|
|||||||
channelId: lastPost.channel_id,
|
channelId: lastPost.channel_id,
|
||||||
comments: PostStore.getCommentCount(lastPost)
|
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();
|
e.preventDefault();
|
||||||
if (document.createEvent) {
|
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);
|
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) {
|
} else if (document.createEventObject) {
|
||||||
var evObj = document.createEventObject();
|
const evObj = document.createEventObject();
|
||||||
document.getElementById('commentIcon0').fireEvent('onclick', evObj);
|
lastPostEl.fireEvent('onclick', evObj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import Constants from 'utils/constants.jsx';
|
|||||||
import DelayedAction from 'utils/delayed_action.jsx';
|
import DelayedAction from 'utils/delayed_action.jsx';
|
||||||
import {Overlay} from 'react-bootstrap';
|
import {Overlay} from 'react-bootstrap';
|
||||||
import EmojiPicker from 'components/emoji_picker/emoji_picker.jsx';
|
import EmojiPicker from 'components/emoji_picker/emoji_picker.jsx';
|
||||||
|
import ChannelStore from 'stores/channel_store.jsx';
|
||||||
|
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
|
|
||||||
@@ -351,6 +352,7 @@ export default class PostInfo extends React.Component {
|
|||||||
idCount={idCount}
|
idCount={idCount}
|
||||||
handleCommentClick={this.props.handleCommentClick}
|
handleCommentClick={this.props.handleCommentClick}
|
||||||
commentCount={this.props.commentCount}
|
commentCount={this.props.commentCount}
|
||||||
|
channelId={ChannelStore.getCurrentId()}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user