From 5cea6a33bde2542d5c7f3994ebfb7697ab2312c6 Mon Sep 17 00:00:00 2001 From: stavlocker <30472563+stavlocker@users.noreply.github.com> Date: Wed, 10 Oct 2018 22:05:17 +0300 Subject: [PATCH] Updated documentation to fix #254 Updated documentation to "fix" #254 - added documentation of arrow key navigation and `setEntryText`. --- README.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/README.md b/README.md index 733abc66..8b3bea4a 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,10 @@ React.render( [3]: http://wookiehangover.github.com/react-typeahead/examples/TypeaheadTokenizer-simple.html [4]: http://blog.npmjs.org/post/85484771375/how-to-install-npm +## Arrow keys navigation + +Typeahead supports selection of elements using the arrow keys (up/down) and ENTER to select. When an item is selected this way, it gains the `hover` class. You can use this class to style the selected item as you wish. + ## API ### Typeahead(props) @@ -224,10 +228,31 @@ If true, custom tags can be added without a matching typeahead selection ### Typeahead ([Exposed Component Functions][reactecf]) +The exposed component functions can be used like so: + +```jsx +//In constructor: +this.typeaheadRef = React.createRef(); //The new way to create refs in react. + +//Somewhere later in the code: + + +//Example usage: +this.typeaheadRef.current.setEntryText(""); +``` #### typeahead.focus Focuses the typeahead input. +#### typeahead.setEntryText(string) + +Accepts: `string` + +Sets the text in the input box. Set to `""` to clear. + --- ### Tokenizer(props)