Skip to content

Conversation

VeraZab
Copy link
Contributor

@VeraZab VeraZab commented Nov 20, 2018

Tested on streambed this time, gives desired result.
screen shot 2018-11-21 at 10 20 17 am
@nicolaskruchten @dmt0 please review

@VeraZab VeraZab changed the title sortMenu adjustments WIP sortMenu adjustments Nov 20, 2018
@VeraZab VeraZab force-pushed the adjust-panels-sort branch 2 times, most recently from f28442a to d4e12e5 Compare November 21, 2018 15:12
@VeraZab VeraZab changed the title WIP sortMenu adjustments sortMenu adjustments Nov 21, 2018
const groupLookup = {};
let groupIndex;
const panels = React.Children.toArray(children);
let childrenArray = React.Children.toArray(children);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could be a ternary... let's try to avoid using let as much as we can please in new code :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in fact, let's go one more step: just always call sortMenu and if menuPanelOrder is null just early-return. much easier to read.


describe('sortMenu', () => {
it('modifies original array to follow the group, then name order provided', () => {
it('returns a new array of sorted children', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes! much more functional :)

Modifying things in-place is almost always a bad idea

@nicolaskruchten
Copy link
Contributor

💃 as-is, but if you want to do my stylistic changes that's fine too :)

@VeraZab
Copy link
Contributor Author

VeraZab commented Nov 26, 2018

Tests were failing due to an intermittent CI failure, merging

@VeraZab VeraZab merged commit 7b017f3 into master Nov 26, 2018
@VeraZab VeraZab deleted the adjust-panels-sort branch November 26, 2018 17:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants