mirror of
https://github.com/flarum/framework.git
synced 2025-05-03 01:54:03 +08:00
Flattening items breaks things; recurse to get the first element instead
This commit is contained in:
parent
558d12c870
commit
3ba495091e
@ -10,7 +10,11 @@ import ActionButton from 'flarum/components/action-button';
|
|||||||
*/
|
*/
|
||||||
export default class DropdownSplit extends Component {
|
export default class DropdownSplit extends Component {
|
||||||
view() {
|
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 items = listItems(this.props.items);
|
||||||
|
|
||||||
var buttonProps = {};
|
var buttonProps = {};
|
||||||
|
@ -64,15 +64,6 @@ export default class ItemList {
|
|||||||
|
|
||||||
array = array.map(item => item.content);
|
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;
|
return array;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user