Flattening items breaks things; recurse to get the first element instead

This commit is contained in:
Toby Zerner 2015-06-26 13:52:54 +09:30
parent f2a28e1185
commit c81cb5dcc8
2 changed files with 5 additions and 10 deletions

View File

@ -10,7 +10,11 @@ import ActionButton from 'flarum/components/action-button';
*/
export default class DropdownSplit extends Component {
view() {
var firstItem = this.props.items[0];
var firstItem = this.props.items;
while (firstItem instanceof Array) {
firstItem = firstItem[0];
}
var items = listItems(this.props.items);
var buttonProps = {};

View File

@ -64,15 +64,6 @@ export default class ItemList {
array = array.map(item => item.content);
//recursively flatten array
for (var i = 0, len = array.length; i < len; i++) {
if (array[i] instanceof Array) {
array = array.concat.apply([], array);
i-- //check current index again and flatten until there are no more nested arrays at that index
len = array.length;
}
}
return array;
}
}