Skip to content

Commit

Permalink
Merge pull request #920 from folio-org/STCOM-480-closedbydefault-no-w…
Browse files Browse the repository at this point in the history
…orkie

STCOM-480 `<AccordionSet>` fails to acknowledge 'closedByDefault' prop of child `<Accordions>`
  • Loading branch information
JohnC-80 committed Mar 20, 2019
2 parents c492ded + 6652e40 commit 41bd2e4
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 5 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# Change history for stripes-components
## [5.1.2](https://github.com/folio-org/stripes-components/tree/v5.1.2) (2019-03-20)
* `<AccordionSet>` consideres `closedByDefault` prop when setting up initial state for child accordions. Fixes STCOM-480.

## [5.1.1](https://github.com/folio-org/stripes-components/tree/v5.1.1) (2019-03-14)
* Consider timezone in Datepicker for values containing a time offset. fixes STCOM-484.
* Check for ref existence within MultiSelection before calling `focus()`. fixes STCOM-485.
Expand Down
2 changes: 1 addition & 1 deletion lib/Accordion/Accordion.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class Accordion extends React.Component {
}

if (this.props.accordionSet) {
this.props.accordionSet.registerAccordion(this.toggle, this.trackingId);
this.props.accordionSet.registerAccordion(this.toggle, this.trackingId, this.props.closedByDefault);
}
}

Expand Down
4 changes: 2 additions & 2 deletions lib/Accordion/AccordionSet.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,13 @@ class AccordionSet extends React.Component {
this.accordionList[this.accordionList.length - 1].focus();
}

registerAccordion(ref, id) {
registerAccordion(ref, id, closedByDefault = false) {
if (indexOf(this.accordionList, ref) === -1 && ref !== null) {
this.accordionList.push(ref);
this.setState((curState) => {
const newState = Object.assign({}, curState);
if (typeof newState.expanded[id] === 'undefined') {
newState.expanded[id] = true;
newState.expanded[id] = !closedByDefault;
}
return newState;
});
Expand Down
3 changes: 2 additions & 1 deletion lib/Accordion/stories/BasicUsage.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@folio/stripes-components",
"version": "5.1.1",
"version": "5.1.2",
"description": "Component library for building Stripes applications.",
"license": "Apache-2.0",
"repository": "folio-org/stripes-components",
Expand Down

0 comments on commit 41bd2e4

Please sign in to comment.