Skip to content

onDropdownToggle event listener added #95

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
9 changes: 7 additions & 2 deletions lib/react-native-multi-select.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -99,7 +100,8 @@ export default class MultiSelect extends Component {
onChangeInput: () => {},
displayKey: 'name',
canAddItems: false,
onAddItem: () => {}
onAddItem: () => {},
onDropdownToggle: () => {}
};

constructor(props) {
Expand Down Expand Up @@ -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)
});
};

Expand All @@ -244,7 +249,7 @@ export default class MultiSelect extends Component {
});
};

_submitSelection = () => {
_submitSelection = () => {
this._toggleSelector();
// reset searchTerm
this._clearSearchTerm();
Expand Down