Skip to content

Commit

Permalink
Components: Remove _.flatMap() from ToolbarGroup and TreeSelect (
Browse files Browse the repository at this point in the history
…#42223)

* Components: Remove _.flatMap from ToolbarGroup and TreeSelect

* Add changelog

* Use .flatMap()
  • Loading branch information
tyxla authored Jul 12, 2022
1 parent d68dedb commit 4719b98
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 2 additions & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
- `ComboboxControl`: Refactor away from `_.deburr()` ([#42169](https://github.com/WordPress/gutenberg/pull/42169/)).
- `FormTokenField`: Refactor away from `_.identity()` ([#42215](https://github.com/WordPress/gutenberg/pull/42215/)).
- `SelectControl`: Use roles and `@testing-library/user-event` in unit tests ([#42308](https://github.com/WordPress/gutenberg/pull/42308)).
- `ToolbarGroup`: Refactor away from `_.flatMap()` ([#42223](https://github.com/WordPress/gutenberg/pull/42223/)).
- `TreeSelect`: Refactor away from `_.flatMap()` ([#42223](https://github.com/WordPress/gutenberg/pull/42223/)).
- `Autocomplete`: Refactor away from `_.deburr()` ([#42266](https://github.com/WordPress/gutenberg/pull/42266/)).
- `MenuItem`: Refactor away from `_.isString()` ([#42268](https://github.com/WordPress/gutenberg/pull/42268/)).
- `Shortcut`: Refactor away from `_.isString()` ([#42268](https://github.com/WordPress/gutenberg/pull/42268/)).
Expand Down
3 changes: 1 addition & 2 deletions packages/components/src/toolbar-group/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* External dependencies
*/
import classnames from 'classnames';
import { flatMap } from 'lodash';

/**
* WordPress dependencies
Expand Down Expand Up @@ -92,7 +91,7 @@ function ToolbarGroup( {

return (
<ToolbarGroupContainer className={ finalClassName } { ...props }>
{ flatMap( controlSets, ( controlSet, indexOfSet ) =>
{ controlSets?.flatMap( ( controlSet, indexOfSet ) =>
controlSet.map( ( control, indexOfControl ) => (
<ToolbarButton
key={ [ indexOfSet, indexOfControl ].join() }
Expand Down
4 changes: 2 additions & 2 deletions packages/components/src/tree-select/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* External dependencies
*/
import { unescape as unescapeString, flatMap, compact } from 'lodash';
import { unescape as unescapeString, compact } from 'lodash';

/**
* WordPress dependencies
Expand All @@ -14,7 +14,7 @@ import { SelectControl } from '../select-control';
import type { TreeSelectProps, Tree, SelectOptions } from './types';

function getSelectOptions( tree: Tree[], level = 0 ): SelectOptions {
return flatMap( tree, ( treeNode ) => [
return tree.flatMap( ( treeNode ) => [
{
value: treeNode.id,
label:
Expand Down

0 comments on commit 4719b98

Please sign in to comment.