Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lodash: Refactor away from _.partial() #43895

Merged
merged 2 commits into from
Sep 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,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 @@ -37,6 +37,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