Skip to content

Commit ffade65

Browse files
committed
Review adjustments
1 parent 69d9a23 commit ffade65

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/components/PanelMenuWrapper.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,7 @@ class PanelsWithSidebar extends Component {
5151
const sections = [];
5252
const groupLookup = {};
5353
let groupIndex;
54-
let childrenArray = React.Children.toArray(children);
55-
56-
if (menuPanelOrder) {
57-
childrenArray = sortMenu(childrenArray, menuPanelOrder);
58-
}
54+
const childrenArray = sortMenu(React.Children.toArray(children), menuPanelOrder);
5955

6056
childrenArray.forEach(child => {
6157
if (!child) {

src/lib/sortMenu.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ function sortAlphabetically(a, b) {
99
}
1010

1111
export default function sortMenu(children, order) {
12+
// Break out early if no order is provided
13+
if (!order) {
14+
return children;
15+
}
16+
1217
// PART 1: only sorting panels (i.e. child with a group and name prop)
1318
// and not other elements (like Buttons, or Logo)
1419
let panelsStartIndex = null;

0 commit comments

Comments
 (0)