Skip to content

Commit 3bae71f

Browse files
authored
Merge pull request magicstone-dev#264 from raboof/dont-autofocus-compose-form
Don't autofocus the compose form
2 parents 4a38ba6 + 2bc8943 commit 3bae71f

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

app/javascript/mastodon/features/compose/components/compose_form.js

+6-7
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import EmojiPickerDropdown from '../containers/emoji_picker_dropdown_container';
1616
import PollFormContainer from '../containers/poll_form_container';
1717
import UploadFormContainer from '../containers/upload_form_container';
1818
import WarningContainer from '../containers/warning_container';
19-
import { isMobile } from '../../../is_mobile';
2019
import ImmutablePureComponent from 'react-immutable-pure-component';
2120
import { length } from 'stringz';
2221
import { countableText } from '../util/counter';
@@ -60,13 +59,13 @@ class ComposeForm extends ImmutablePureComponent {
6059
onChangeSpoilerText: PropTypes.func.isRequired,
6160
onPaste: PropTypes.func.isRequired,
6261
onPickEmoji: PropTypes.func.isRequired,
63-
showSearch: PropTypes.bool,
62+
autoFocus: PropTypes.bool,
6463
anyMedia: PropTypes.bool,
6564
singleColumn: PropTypes.bool,
6665
};
6766

6867
static defaultProps = {
69-
showSearch: false,
68+
autoFocus: false,
7069
};
7170

7271
handleChange = (e) => {
@@ -148,7 +147,7 @@ class ComposeForm extends ImmutablePureComponent {
148147
// - Replying to zero or one users, places the cursor at the end of the textbox.
149148
// - Replying to more than one user, selects any usernames past the first;
150149
// this provides a convenient shortcut to drop everyone else from the conversation.
151-
if (this.props.focusDate !== prevProps.focusDate) {
150+
if (this.props.focusDate && this.props.focusDate !== prevProps.focusDate) {
152151
let selectionEnd, selectionStart;
153152

154153
if (this.props.preselectDate !== prevProps.preselectDate) {
@@ -169,7 +168,7 @@ class ComposeForm extends ImmutablePureComponent {
169168
} else if (this.props.spoiler !== prevProps.spoiler) {
170169
if (this.props.spoiler) {
171170
this.spoilerText.input.focus();
172-
} else {
171+
} else if (prevProps.spoiler) {
173172
this.autosuggestTextarea.textarea.focus();
174173
}
175174
}
@@ -196,7 +195,7 @@ class ComposeForm extends ImmutablePureComponent {
196195
}
197196

198197
render () {
199-
const { intl, onPaste, showSearch } = this.props;
198+
const { intl, onPaste, autoFocus } = this.props;
200199
const disabled = this.props.isSubmitting;
201200
let publishText = '';
202201

@@ -243,7 +242,7 @@ class ComposeForm extends ImmutablePureComponent {
243242
onSuggestionsClearRequested={this.onSuggestionsClearRequested}
244243
onSuggestionSelected={this.onSuggestionSelected}
245244
onPaste={onPaste}
246-
autoFocus={!showSearch && !isMobile(window.innerWidth)}
245+
autoFocus={autoFocus}
247246
>
248247
<EmojiPickerDropdown onPickEmoji={this.handleEmojiPick} />
249248
<div className='compose-form__modifiers'>

app/javascript/mastodon/features/compose/containers/compose_form_container.js

-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ const mapStateToProps = state => ({
2424
isSubmitting: state.getIn(['compose', 'is_submitting']),
2525
isChangingUpload: state.getIn(['compose', 'is_changing_upload']),
2626
isUploading: state.getIn(['compose', 'is_uploading']),
27-
showSearch: state.getIn(['search', 'submitted']) && !state.getIn(['search', 'hidden']),
2827
anyMedia: state.getIn(['compose', 'media_attachments']).size > 0,
2928
});
3029

app/javascript/mastodon/features/compose/index.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import elephantUIPlane from '../../../images/elephant_ui_plane.svg';
1717
import { mascot } from '../../initial_state';
1818
import Icon from 'mastodon/components/icon';
1919
import { logOut } from 'mastodon/utils/log_out';
20+
import { isMobile } from '../../is_mobile';
2021

2122
const messages = defineMessages({
2223
start: { id: 'getting_started.heading', defaultMessage: 'Getting started' },
@@ -127,7 +128,7 @@ class Compose extends React.PureComponent {
127128
{!isSearchPage && <div className='drawer__inner' onFocus={this.onFocus}>
128129
<NavigationContainer onClose={this.onBlur} />
129130

130-
<ComposeFormContainer />
131+
<ComposeFormContainer autoFocus={!isMobile(window.innerWidth)} />
131132

132133
<div className='drawer__inner__mastodon'>
133134
<img alt='' draggable='false' src={mascot || elephantUIPlane} />

0 commit comments

Comments
 (0)