gearheads
/
mastodon
Archived
2
0
Fork 0

Disabled auto focus on toot form when search results are shown. (#2942)

gh/stable
fusshi- 2017-05-10 09:51:43 +09:00 committed by Eugen Rochko
parent 682507bc3c
commit 29d8313b28
3 changed files with 17 additions and 5 deletions

View File

@ -153,7 +153,7 @@ class AutosuggestTextarea extends ImmutablePureComponent {
} }
render () { render () {
const { value, suggestions, disabled, placeholder, onKeyUp } = this.props; const { value, suggestions, disabled, placeholder, onKeyUp, autoFocus } = this.props;
const { suggestionsHidden, selectedSuggestion } = this.state; const { suggestionsHidden, selectedSuggestion } = this.state;
const style = { direction: 'ltr' }; const style = { direction: 'ltr' };
@ -168,7 +168,7 @@ class AutosuggestTextarea extends ImmutablePureComponent {
className='autosuggest-textarea__textarea' className='autosuggest-textarea__textarea'
disabled={disabled} disabled={disabled}
placeholder={placeholder} placeholder={placeholder}
autoFocus={true} autoFocus={autoFocus}
value={value} value={value}
onChange={this.onChange} onChange={this.onChange}
onKeyDown={this.onKeyDown} onKeyDown={this.onKeyDown}
@ -208,6 +208,11 @@ AutosuggestTextarea.propTypes = {
onKeyUp: PropTypes.func, onKeyUp: PropTypes.func,
onKeyDown: PropTypes.func, onKeyDown: PropTypes.func,
onPaste: PropTypes.func.isRequired, onPaste: PropTypes.func.isRequired,
autoFocus: PropTypes.bool
};
AutosuggestTextarea.defaultProps = {
autoFucus: true,
}; };
export default AutosuggestTextarea; export default AutosuggestTextarea;

View File

@ -118,7 +118,7 @@ class ComposeForm extends ImmutablePureComponent {
} }
render () { render () {
const { intl, onPaste } = this.props; const { intl, onPaste, showSearch } = this.props;
const disabled = this.props.is_submitting; const disabled = this.props.is_submitting;
const text = [this.props.spoiler_text, this.props.text].join(''); const text = [this.props.spoiler_text, this.props.text].join('');
@ -156,6 +156,7 @@ class ComposeForm extends ImmutablePureComponent {
onSuggestionsClearRequested={this.onSuggestionsClearRequested} onSuggestionsClearRequested={this.onSuggestionsClearRequested}
onSuggestionSelected={this.onSuggestionSelected} onSuggestionSelected={this.onSuggestionSelected}
onPaste={onPaste} onPaste={onPaste}
autoFocus={!showSearch}
/> />
<EmojiPickerDropdown onPickEmoji={this.handleEmojiPick} /> <EmojiPickerDropdown onPickEmoji={this.handleEmojiPick} />
@ -204,7 +205,12 @@ ComposeForm.propTypes = {
onSuggestionSelected: PropTypes.func.isRequired, onSuggestionSelected: PropTypes.func.isRequired,
onChangeSpoilerText: PropTypes.func.isRequired, onChangeSpoilerText: PropTypes.func.isRequired,
onPaste: PropTypes.func.isRequired, onPaste: PropTypes.func.isRequired,
onPickEmoji: PropTypes.func.isRequired onPickEmoji: PropTypes.func.isRequired,
showSearch: PropTypes.bool,
};
ComposeForm.defaultProps = {
showSearch: false
}; };
export default injectIntl(ComposeForm); export default injectIntl(ComposeForm);

View File

@ -22,7 +22,8 @@ const mapStateToProps = state => ({
preselectDate: state.getIn(['compose', 'preselectDate']), preselectDate: state.getIn(['compose', 'preselectDate']),
is_submitting: state.getIn(['compose', 'is_submitting']), is_submitting: state.getIn(['compose', 'is_submitting']),
is_uploading: state.getIn(['compose', 'is_uploading']), is_uploading: state.getIn(['compose', 'is_uploading']),
me: state.getIn(['compose', 'me']) me: state.getIn(['compose', 'me']),
showSearch: state.getIn(['search', 'submitted']) && !state.getIn(['search', 'hidden'])
}); });
const mapDispatchToProps = (dispatch) => ({ const mapDispatchToProps = (dispatch) => ({