Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

[MM-9771] Cursor focus doesn't return to comment box on the RHS after editing a message on the RHS by removing all of the text in the comment #925

Merged
merged 1 commit into from
Mar 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fixes cursor focus (#8429)
  • Loading branch information
letsila committed Mar 10, 2018
commit 0e778c280a16dbd9397c12cc12b6b57d5cd6f556
4 changes: 2 additions & 2 deletions actions/post_actions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ export function doPostAction(postId, actionId) {
PostActions.doPostAction(postId, actionId)(dispatch, getState);
}

export function setEditingPost(postId = '', commentsCount = 0, refocusId = '', title = '') {
export function setEditingPost(postId = '', commentsCount = 0, refocusId = '', title = '', isRHS = false) {
return async (doDispatch, doGetState) => {
const state = doGetState();

Expand All @@ -311,7 +311,7 @@ export function setEditingPost(postId = '', commentsCount = 0, refocusId = '', t
if (canEditNow) {
doDispatch({
type: ActionTypes.SHOW_EDIT_POST_MODAL,
data: {postId, commentsCount, refocusId, title},
data: {postId, commentsCount, refocusId, title, isRHS},
}, doGetState);
}

Expand Down
2 changes: 2 additions & 0 deletions components/dot_menu/dot_menu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export default class DotMenu extends Component {
post: {},
commentCount: 0,
isFlagged: false,
isRHS: false,
}

constructor(props) {
Expand Down Expand Up @@ -193,6 +194,7 @@ export default class DotMenu extends Component {
dotMenuEdit = (
<DotMenuEdit
idPrefix={idPrefix + 'Edit'}
isRHS={this.props.isRHS}
idCount={this.props.idCount}
post={this.props.post}
type={type}
Expand Down
4 changes: 3 additions & 1 deletion components/dot_menu/dot_menu_edit.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ export default function DotMenuEdit(props) {
props.post.id,
props.commentsCount,
props.idPrefix.indexOf(Constants.CENTER) === 0 ? 'post_textbox' : 'reply_textbox',
props.idPrefix.indexOf(Constants.CENTER) === 0 ? props.type : Utils.localizeMessage('rhs_comment.comment', 'Comment')
props.idPrefix.indexOf(Constants.CENTER) === 0 ? props.type : Utils.localizeMessage('rhs_comment.comment', 'Comment'),
props.isRHS
);
}

Expand All @@ -48,6 +49,7 @@ export default function DotMenuEdit(props) {

DotMenuEdit.propTypes = {
idPrefix: PropTypes.string.isRequired,
isRHS: PropTypes.bool,
idCount: PropTypes.number,
post: PropTypes.object,
type: PropTypes.string,
Expand Down
7 changes: 6 additions & 1 deletion components/edit_post_modal/edit_post_modal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ export default class EditPostModal extends React.PureComponent {
* What to show in the title of the modal as "Edit {title}"
*/
title: PropTypes.string,

/**
* Whether or not the modal was open from RHS
*/
isRHS: PropTypes.bool,
}).isRequired,

actions: PropTypes.shape({
Expand Down Expand Up @@ -160,7 +165,7 @@ export default class EditPostModal extends React.PureComponent {
const hasAttachment = editingPost.post.file_ids && editingPost.post.file_ids.length > 0;
if (updatedPost.message.trim().length === 0 && !hasAttachment) {
this.handleHide(false);
GlobalActions.showDeletePostModal(Selectors.getPost(getState(), editingPost.postId), editingPost.commentsCount);
GlobalActions.showDeletePostModal(Selectors.getPost(getState(), editingPost.postId), editingPost.commentsCount, editingPost.isRHS);
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ exports[`components/dot_menu/DotMenu should match snapshot, canDelete 1`] = `
commentCount={0}
idCount={-1}
idPrefix="centerDotMenuDelete"
isRHS={false}
post={
Object {
"id": "post_id_1",
Expand Down
1 change: 1 addition & 0 deletions tests/components/dot_menu/dot_menu.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ describe('components/dot_menu/DotMenu', () => {
idCount: -1,
post: {id: 'post_id_1', is_pinned: false},
isFlagged: false,
isRHS: false,
handleCommentClick: jest.fn(),
handleDropdownOpened: jest.fn(),
actions: {
Expand Down
5 changes: 3 additions & 2 deletions tests/components/dot_menu/dot_menu_edit.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ describe('components/dot_menu/DotMenuEdit', () => {
post: {id: 'post_id_1'},
type: 'Post',
commentsCount: 1,
isRHS: false,
actions: {setEditingPost: jest.fn()},
};

Expand All @@ -26,7 +27,7 @@ describe('components/dot_menu/DotMenuEdit', () => {

wrapper.find('button').first().simulate('click');
expect(baseProps.actions.setEditingPost).toHaveBeenCalledTimes(1);
expect(baseProps.actions.setEditingPost).toHaveBeenCalledWith('post_id_1', 1, 'post_textbox', 'Post');
expect(baseProps.actions.setEditingPost).toHaveBeenCalledWith('post_id_1', 1, 'post_textbox', 'Post', false);

expect(wrapper.find('#center2').exists()).toBe(false);
wrapper.setProps({idCount: 2});
Expand All @@ -43,7 +44,7 @@ describe('components/dot_menu/DotMenuEdit', () => {

wrapper.find('button').first().simulate('click');
expect(baseProps.actions.setEditingPost).toHaveBeenCalledTimes(1);
expect(baseProps.actions.setEditingPost).toHaveBeenCalledWith('post_id_1', 1, 'reply_textbox', 'Comment');
expect(baseProps.actions.setEditingPost).toHaveBeenCalledWith('post_id_1', 1, 'reply_textbox', 'Comment', false);

expect(wrapper.find('#rhs3').exists()).toBe(false);
wrapper.setProps({idCount: 3});
Expand Down
2 changes: 2 additions & 0 deletions tests/redux/actions/posts.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ describe('Actions.Posts', () => {
refocusId: 'test',
show: true,
title: 'title',
isRHS: false,
}
);

Expand All @@ -36,6 +37,7 @@ describe('Actions.Posts', () => {
refocusId: 'test2',
show: true,
title: 'title2',
isRHS: false,
}
);
});
Expand Down