Skip to content

Commit

Permalink
Add imperative focusTextInput() method
Browse files Browse the repository at this point in the history
  • Loading branch information
cooperka committed Aug 28, 2017
1 parent b669f3b commit 013b310
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@ e.g.
- **`onInputTextChanged`** _(Function)_ - Callback when the input text changes
- **`maxInputLength`** _(Integer)_ - Max message composer TextInput length

## Imperative methods

- `focusTextInput()` - Open the keyboard and focus the text input box

## Notes for [Redux](https://github.com/reactjs/redux)

The `messages` prop should work out-of-the-box with Redux. In most cases this is all you need.
Expand Down
6 changes: 6 additions & 0 deletions src/GiftedChat.js
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,12 @@ class GiftedChat extends React.Component {
});
}

focusTextInput() {
if (this.textInput) {
this.textInput.focus();
}
}

onInputSizeChanged(size) {
const newComposerHeight = Math.max(MIN_COMPOSER_HEIGHT, Math.min(MAX_COMPOSER_HEIGHT, size.height));
const newMessagesContainerHeight = this.getMessagesContainerHeightWithKeyboard(newComposerHeight);
Expand Down

0 comments on commit 013b310

Please sign in to comment.