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

fix: Dropdown disabled toggle issue #1571

Merged
merged 2 commits into from Jul 12, 2019

Conversation

bpas247
Copy link
Member

@bpas247 bpas247 commented Jul 11, 2019

  • Bug fix
  • New feature
  • Chore
  • Breaking change
  • There is an open issue which this change addresses
  • [xI have read the CONTRIBUTING document.
  • My commits follow the Git Commit Guidelines
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
    • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

This fix addresses the issue where Dropdown will be passed a
disabled prop, yet it is still clickable. This is due to context
being passed the user-defined toggle prop directly, rather than
our defined this.toggle function that includes a check for
disabled.

Fixes #1542

This fix addresses the issue where Dropdown will be passed a
`disabled` prop, yet it is still clickable. This is due to context
being passed the user-defined `toggle` prop directly, rather than
our defined `this.toggle` function that includes a check for
`disabled`.

Fixes reactstrap#1542
@bpas247
Copy link
Member Author

bpas247 commented Jul 12, 2019

hmm, I'm not exactly sure why those tests are failing, they seem unrelated to the changes I committed.

Anyone have any ideas what could be causing this?

@TheSharpieOne
Copy link
Member

I think you found some bad tests. It looks like it was expecting the Dropdown toggle to not be called... when it should have been getting called. Since you fixed it to call Dropdown's toggle (which in turn calls the user's toggle), those tests fail.

In reality, those tests probably should have been failing this whole time and this PR would have make them pass.

Can you change expect(Dropdown.prototype.toggle.mock.calls.length).toBe(0); to expect(Dropdown.prototype.toggle.mock.calls.length).toBe(1); in both of those tests to get them to pass as they should be expecting Dropdown's toggle to be called 1 time.

@bpas247
Copy link
Member Author

bpas247 commented Jul 12, 2019

Can you change expect(Dropdown.prototype.toggle.mock.calls.length).toBe(0); to expect(Dropdown.prototype.toggle.mock.calls.length).toBe(1); in both of those tests to get them to pass as they should be expecting Dropdown's toggle to be called 1 time.

I had a feeling they were wrong 😉 will do 👍

In the previous implementation, Dropdown wasn't properly firing
the toggle function within Dropdown, so the assertion was written
down wrong to compensate for that.
@TheSharpieOne TheSharpieOne merged commit b4edeb8 into reactstrap:master Jul 12, 2019
@bpas247 bpas247 deleted the fix/dropdown-disabled branch July 12, 2019 22:37
nathanbacon added a commit to nathanbacon/reactstrap that referenced this pull request Jul 19, 2019
This applies the CustomEvent polyfill recommended in the [MDN web
docs](https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/CustomEvent#Polyfill). This also applies a simple polyfill I found in the (react-transition-group module)[https://github.com/reactjs/react-transition-group/blob/9e3b2d3c09b78e755bdc837b7b38337812ede2c9/src/TransitionGroup.js#L11].

I don't think this has much potential to break anything, since these
will only impact browswers where these features are already broken.
nathanbacon added a commit to nathanbacon/reactstrap that referenced this pull request Jul 19, 2019
This applies the CustomEvent polyfill recommended in the MDN web docs (https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/CustomEvent#Polyfill).
This also applies a simple polyfill for Object.values I found in the react-transition-group module (https://github.com/reactjs/react-transition-group/blob/9e3b2d3c09b78e755bdc837b7b38337812ede2c9/src/TransitionGroup.js#L11).

Fixes reactstrap#1571
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.

Dropdown disabled style inconsistent
2 participants