diff --git a/README.md b/README.md index ea318324..0451f286 100644 --- a/README.md +++ b/README.md @@ -242,6 +242,9 @@ These functions are accessible by setting "ref" on the component (see example be #### focus() Call `focus` to focus on the element. The suggest list will be expanded with the current suggestions. +#### blur() +Call `blur` to blur (unfocus) the element. The suggest list will be closed. + #### update(value) It is possible to update the value of the input contained within the GeoSuggest component by calling the `update` function with a new desired `value` of the type String. diff --git a/src/Geosuggest.jsx b/src/Geosuggest.jsx index ecad0084..e9c6da0f 100644 --- a/src/Geosuggest.jsx +++ b/src/Geosuggest.jsx @@ -144,6 +144,13 @@ class Geosuggest extends React.Component { this.refs.input.focus(); } + /** + * Blur the input + */ + blur() { + this.refs.input.blur(); + } + /** * Update the value of the user input * @param {String} userInput the new value of the user input diff --git a/src/input.jsx b/src/input.jsx index 2154cda9..1a74372b 100644 --- a/src/input.jsx +++ b/src/input.jsx @@ -91,6 +91,13 @@ class Input extends React.Component { this.refs.input.focus(); } + /** + * Blur the input + */ + blur() { + this.refs.input.blur(); + } + /** * Render the view * @return {Function} The React element to render