Skip to content
Snippets Groups Projects
Commit c4354395 authored by Tom Robinson's avatar Tom Robinson
Browse files

Move search field to top of AccordianList if alwaysExpanded=true

parent 23978bd6
No related branches found
No related tags found
No related merge requests found
......@@ -243,6 +243,9 @@ export default class AccordianList extends Component {
const sectionIsTogglable = sectionIndex =>
alwaysTogglable || sections.length > 1;
// if any section is searchable just enable a global search
let globalSearch = false;
const rows = [];
for (const [sectionIndex, section] of sections.entries()) {
const isLastSection = sectionIndex === sections.length - 1;
......@@ -265,7 +268,11 @@ export default class AccordianList extends Component {
section.items &&
section.items.length > 0
) {
rows.push({ type: "search", section, sectionIndex, isLastSection });
if (alwaysExpanded) {
globalSearch = true;
} else {
rows.push({ type: "search", section, sectionIndex, isLastSection });
}
}
if (
sectionIsExpanded(sectionIndex) &&
......@@ -295,6 +302,15 @@ export default class AccordianList extends Component {
}
}
if (globalSearch) {
rows.unshift({
type: "search",
section: {},
sectionIndex: 0,
isLastSection: false,
});
}
const maxHeight =
this.props.maxHeight > 0 && this.props.maxHeight < Infinity
? this.props.maxHeight
......
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