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(Accordion): respect defaultActiveIndex #763

Merged
merged 1 commit into from
Oct 28, 2016

Conversation

levithomason
Copy link
Member

@levithomason levithomason commented Oct 28, 2016

Fixes #761

The defaultActiveIndex is overridden in the Accordion on componentWillMount. This PR adds an inline manual check for the default prop and a TODO to resolve the bug. I've also added 2 tests to assert the initial index of -1 and the default prop works correctly.

This is an edge case, but we need to update the AutoControlledComponent to defer to default props when calling trySetState in componentWillMount.

The real solve here is likely adding static defaultAutoControlledProps. Currently, the AutoControlledComponent tells devs to use trySetState in componentWillMount instead of setting defaults for auto controlled props. This is to prevent the actual defaults from always winning, however, if we had our own auto controlled defaults then we could apply them correctly.

@codecov-io
Copy link

Current coverage is 99.49% (diff: 100%)

Merging #763 into master will increase coverage by <.01%

@@             master       #763   diff @@
==========================================
  Files           134        134          
  Lines          2156       2157     +1   
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
+ Hits           2145       2146     +1   
  Misses           11         11          
  Partials          0          0          

Powered by Codecov. Last update 909ea45...5f3945d

@levithomason levithomason merged commit 8c49cf0 into master Oct 28, 2016
@levithomason levithomason deleted the fix/accordion-activeindex branch October 28, 2016 22:55
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.

Accordion defaultActiveIndex
2 participants