Skip to content
Snippets Groups Projects
Commit 6f0c163a authored by Allen Gilliland's avatar Allen Gilliland
Browse files

Merge pull request #1807 from metabase/fix-metric-selection

Fix Metric section selection
parents 839350a3 a92a7b17
No related branches found
No related tags found
No related merge requests found
......@@ -3,14 +3,31 @@ import React, { Component, PropTypes } from "react";
import Icon from "metabase/components/Icon.jsx";
import cx from "classnames";
import _ from "underscore";
export default class AccordianList extends Component {
constructor(props, context) {
super(props, context);
let openSection;
// use initiallyOpenSection prop if present
if (props.initiallyOpenSection !== undefined) {
openSection = props.initiallyOpenSection;
}
// otherwise try to find the selected section, if any
if (openSection === undefined) {
openSection = _.findIndex(props.sections, (section, index) => this.sectionIsSelected(section, index));
if (openSection === -1) {
openSection = undefined;
}
}
// default to the first section
if (openSection === undefined) {
openSection = 0;
}
this.state = {
openSection: props.initiallyOpenSection
openSection
};
}
......@@ -26,10 +43,6 @@ export default class AccordianList extends Component {
getItemClasses: PropTypes.func
};
static defaultProps = {
initiallyOpenSection: 0
};
toggleSection(sectionIndex) {
if (this.props.onChangeSection) {
if (this.props.onChangeSection(sectionIndex) === false) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment