this.setState({ suggestionsHidden: true, focused: false });
}
- onFocus = () => {
+ onFocus = (e) => {
this.setState({ focused: true });
+ if (this.props.onFocus) {
+ this.props.onFocus(e);
+ }
}
onSuggestionClick = (e) => {
export default @injectIntl
class ComposeForm extends ImmutablePureComponent {
+ setRef = c => {
+ this.composeForm = c;
+ };
+
static contextTypes = {
router: PropTypes.object,
};
}
}
+ handleFocus = () => {
+ this.composeForm.scrollIntoView();
+ }
+
// This statement does several things:
// - If we're beginning a reply, and,
// - Replying to zero or one users, places the cursor at the end
let disabledButton = isSubmitting || isUploading || isChangingUpload || (!text.trim().length && !anyMedia);
return (
- <div className='composer'>
+ <div className='composer' ref={this.setRef}>
<WarningContainer />
<ReplyIndicatorContainer />
value={this.props.text}
onChange={this.handleChange}
suggestions={this.props.suggestions}
+ onFocus={this.handleFocus}
onKeyDown={this.handleKeyDown}
onSuggestionsFetchRequested={onFetchSuggestions}
onSuggestionsClearRequested={onClearSuggestions}