Commit 290fd2dd authored by Tsilavina Razafinirina's avatar Tsilavina Razafinirina Committed by Saturnino Abril

Return cursor to reply thread input box after deleting a reply from the...

Return cursor to reply thread input box after deleting a reply from the right-hand sidebar (#8336) (#879)

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

* Add props validation for RHS  (#8336)
parent ec106d94
......@@ -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,
});
......
......@@ -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: '',
});
......@@ -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();
}
}
}
......
......@@ -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,
......@@ -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}
......
......@@ -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 = {};
......@@ -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,
......
......@@ -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}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment