diff --git a/README.md b/README.md index b536064..a860285 100644 --- a/README.md +++ b/README.md @@ -160,6 +160,8 @@ The component takes 3 compulsory props - `items`, `uniqueKey` and `onSelectedIte | textInputProps | No | (Object) Properties for the Text Input. Pass any property that is required on the text input | | uniqueKey | Yes | (String) Unique identifier that is part of each item's properties. Used internally as means of identifying each item (Check sample below) | |selectedItems | No | (Array, control prop) List of selected items keys . JavaScript Array of strings, that can be instantiated with the component | +| onDropdownToggle | No | (Function) JavaScript function passed in as an argument. The function is called everythime the dropdown is opened/closed. Recive the dropdown status (`true` if opened, `false` if closed) in first argument. | + ## Note diff --git a/lib/react-native-multi-select.js b/lib/react-native-multi-select.js index a576931..9922b16 100644 --- a/lib/react-native-multi-select.js +++ b/lib/react-native-multi-select.js @@ -63,6 +63,7 @@ export default class MultiSelect extends Component { canAddItems: PropTypes.bool, onAddItem: PropTypes.func, onChangeInput: PropTypes.func, + onDropdownToggle: PropTypes.func, displayKey: PropTypes.string, textInputProps: PropTypes.object, flatListProps: PropTypes.object @@ -99,7 +100,8 @@ export default class MultiSelect extends Component { onChangeInput: () => {}, displayKey: 'name', canAddItems: false, - onAddItem: () => {} + onAddItem: () => {}, + onDropdownToggle: () => {} }; constructor(props) { @@ -233,8 +235,11 @@ export default class MultiSelect extends Component { }; _toggleSelector = () => { + const { onDropdownToggle } = this.props; this.setState({ selector: !this.state.selector + }, () => { + onDropdownToggle(this.state.selector) }); }; @@ -244,7 +249,7 @@ export default class MultiSelect extends Component { }); }; - _submitSelection = () => { + _submitSelection = () => { this._toggleSelector(); // reset searchTerm this._clearSearchTerm();