Skip to content

Commit

Permalink
Fix text being incorrectly pre-selected in composer textarea on /share (
Browse files Browse the repository at this point in the history
  • Loading branch information
ClearlyClaire authored and jesseplusplus committed Feb 10, 2022
1 parent 22050df commit 8fa2c04
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class ComposeForm extends ImmutablePureComponent {
onPickEmoji: PropTypes.func.isRequired,
showSearch: PropTypes.bool,
anyMedia: PropTypes.bool,
isInReply: PropTypes.bool,
singleColumn: PropTypes.bool,
};

Expand Down Expand Up @@ -149,7 +150,7 @@ class ComposeForm extends ImmutablePureComponent {
if (this.props.focusDate !== prevProps.focusDate) {
let selectionEnd, selectionStart;

if (this.props.preselectDate !== prevProps.preselectDate) {
if (this.props.preselectDate !== prevProps.preselectDate && this.props.isInReply) {
selectionEnd = this.props.text.length;
selectionStart = this.props.text.search(/\s/) + 1;
} else if (typeof this.props.caretPosition === 'number') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const mapStateToProps = state => ({
isUploading: state.getIn(['compose', 'is_uploading']),
showSearch: state.getIn(['search', 'submitted']) && !state.getIn(['search', 'hidden']),
anyMedia: state.getIn(['compose', 'media_attachments']).size > 0,
isInReply: state.getIn(['compose', 'in_reply_to']) !== null,
});

const mapDispatchToProps = (dispatch) => ({
Expand Down

0 comments on commit 8fa2c04

Please sign in to comment.