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

Commit

Permalink
Return cursor to reply thread input box after deleting a reply from t…
Browse files Browse the repository at this point in the history
…he right-hand sidebar (#8336) (#879)

* Fixes cursor position on RHS after reply deletion (#8336)

* Add props validation for RHS  (#8336)
  • Loading branch information
letsila authored and saturninoabril committed Mar 9, 2018
1 parent ec106d9 commit 290fd2d
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 3 deletions.
3 changes: 2 additions & 1 deletion actions/global_actions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,11 @@ export function toggleShortcutsModal() {
});
}

export function showDeletePostModal(post, commentCount = 0) {
export function showDeletePostModal(post, commentCount = 0, isRHS) {
AppDispatcher.handleViewAction({
type: ActionTypes.TOGGLE_DELETE_POST_MODAL,
value: true,
isRHS,
post,
commentCount,
});
Expand Down
7 changes: 6 additions & 1 deletion components/delete_post_modal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export default class DeletePostModal extends React.Component {
this.setState({
show: value,
post: args.post,
isRHS: args.isRHS,
commentCount: args.commentCount,
error: '',
});
Expand All @@ -68,7 +69,11 @@ export default class DeletePostModal extends React.Component {
this.setState({show: false});

if (!UserAgent.isMobile()) {
document.getElementById('post_textbox').focus();
if (this.state.isRHS) {
document.getElementById('reply_textbox').focus();
} else {
document.getElementById('post_textbox').focus();
}
}
}

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 @@ -21,6 +21,7 @@ export default class DotMenu extends Component {
post: PropTypes.object.isRequired,
commentCount: PropTypes.number,
isFlagged: PropTypes.bool,
isRHS: PropTypes.bool,
handleCommentClick: PropTypes.func,
handleDropdownOpened: PropTypes.func,

Expand Down Expand Up @@ -179,6 +180,7 @@ export default class DotMenu extends Component {
dotMenuDelete = (
<DotMenuItem
idPrefix={idPrefix + 'Delete'}
isRHS={this.props.isRHS}
idCount={this.props.idCount}
post={this.props.post}
commentCount={type === 'Post' ? this.props.commentCount : 0}
Expand Down
3 changes: 2 additions & 1 deletion components/dot_menu/dot_menu_item.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default function DotMenuItem(props) {

function handleDeletePost(e) {
e.preventDefault();
showDeletePostModal(props.post, props.commentCount);
showDeletePostModal(props.post, props.commentCount, props.isRHS);
}

const attrib = {};
Expand Down Expand Up @@ -94,6 +94,7 @@ export default function DotMenuItem(props) {
DotMenuItem.propTypes = {
idPrefix: PropTypes.string.isRequired,
idCount: PropTypes.number,
isRHS: PropTypes.bool,
post: PropTypes.object,
handleOnClick: PropTypes.func,
commentCount: PropTypes.number,
Expand Down
1 change: 1 addition & 0 deletions components/rhs_comment/rhs_comment.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ export default class RhsComment extends React.Component {
const dotMenu = (
<DotMenu
idPrefix={Constants.RHS}
isRHS={true}
idCount={idCount}
post={this.props.post}
isFlagged={this.props.isFlagged}
Expand Down

0 comments on commit 290fd2d

Please sign in to comment.