Skip to content
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

Add toggle switch to DropdownItem to allow conditional toggle #346

Merged
merged 8 commits into from
Mar 31, 2017
Merged

Add toggle switch to DropdownItem to allow conditional toggle #346

merged 8 commits into from
Mar 31, 2017

Conversation

JoeCreoterra
Copy link
Contributor

In the current master the dropdown toggle is called whenever a DropdownItem is clicked. This interferes with using the Dropdown for multiselect purposes. My proposal adds a toggle switch that defaults to true, so that the current default behaviour stays the same, but an optional toggle prop can be set to {false} which then skips the call to this.context.toggle and allows the menu to stay open on DropdownItem onClick.

@@ -40,7 +43,9 @@ class DropdownItem extends React.Component {
this.props.onClick(e);
}

this.context.toggle();
if (this.props.toggle) {
this.context.toggle();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rethinking this, bool seems fine for preventing toggle. But, if a function is passed to toggle prop, we should probably call that instead of context. That can be an enhancement pr that should be backwards compatible.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I completely agree, I'll do this and create a new PR as soon as I have some time.

@eddywashere eddywashere merged commit 578a61b into reactstrap:master Mar 31, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants