mirror of
https://github.com/flarum/framework.git
synced 2024-12-11 21:43:38 +08:00
Flattening items breaks things; recurse to get the first element instead
This commit is contained in:
parent
f2a28e1185
commit
c81cb5dcc8
|
@ -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 = {};
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user