Skip to content

Commit

Permalink
Lodash: Refactor away from _.partial() (#43895)
Browse files Browse the repository at this point in the history
* Lodash: Refactor away from _.partial()

* Add components CHANGELOG
  • Loading branch information
tyxla authored Sep 6, 2022
1 parent eef6094 commit ea86d7b
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 12 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ module.exports = {
'nth',
'once',
'overEvery',
'partial',
'partialRight',
'random',
'reject',
Expand Down
1 change: 1 addition & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
- `ComboboxControl`: updated to satisfy `react/exhuastive-deps` eslint rule ([#41417](https://github.com/WordPress/gutenberg/pull/41417))
- `FormTokenField`: Refactor away from Lodash ([#43744](https://github.com/WordPress/gutenberg/pull/43744/)).
- `NavigatorButton`: updated to satisfy `react/exhaustive-deps` eslint rule ([#42051](https://github.com/WordPress/gutenberg/pull/42051))
- `TabPanel`: Refactor away from `_.partial()` ([#43895](https://github.com/WordPress/gutenberg/pull/43895/)).

## 20.0.0 (2022-08-24)

Expand Down
4 changes: 2 additions & 2 deletions packages/components/src/tab-panel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* External dependencies
*/
import classnames from 'classnames';
import { partial, find } from 'lodash';
import { find } from 'lodash';

/**
* WordPress dependencies
Expand Down Expand Up @@ -127,7 +127,7 @@ export function TabPanel( {
aria-controls={ `${ instanceId }-${ tab.name }-view` }
selected={ tab.name === selected }
key={ tab.name }
onClick={ partial( handleClick, tab.name ) }
onClick={ () => handleClick( tab.name ) }
>
{ tab.title }
</TabButton>
Expand Down
9 changes: 3 additions & 6 deletions packages/edit-post/src/components/block-manager/checklist.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
/**
* External dependencies
*/
import { partial } from 'lodash';

/**
* WordPress dependencies
*/
Expand All @@ -25,7 +20,9 @@ function BlockTypesChecklist( { blockTypes, value, onItemChange } ) {
</>
}
checked={ value.includes( blockType.name ) }
onChange={ partial( onItemChange, blockType.name ) }
onChange={ ( ...args ) =>
onItemChange( blockType.name, ...args )
}
/>
</li>
) ) }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* External dependencies
*/
import { get, partial } from 'lodash';
import { get } from 'lodash';

/**
* WordPress dependencies
Expand Down Expand Up @@ -66,7 +66,8 @@ const applyWithDispatch = withDispatch( ( dispatch ) => {
const { toggleEditorPanelOpened } = dispatch( editPostStore );

return {
onTogglePanel: partial( toggleEditorPanelOpened, PANEL_NAME ),
onTogglePanel: ( ...args ) =>
toggleEditorPanelOpened( PANEL_NAME, ...args ),
};
} );

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* External dependencies
*/
import { get, partial } from 'lodash';
import { get } from 'lodash';

/**
* WordPress dependencies
Expand Down Expand Up @@ -46,7 +46,8 @@ export function PageAttributes() {
return null;
}

const onTogglePanel = partial( toggleEditorPanelOpened, PANEL_NAME );
const onTogglePanel = ( ...args ) =>
toggleEditorPanelOpened( PANEL_NAME, ...args );

return (
<PageAttributesCheck>
Expand Down

0 comments on commit ea86d7b

Please sign in to comment.