Skip to content

Commit

Permalink
Avoid omit utility
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad committed May 20, 2024
1 parent 8d31955 commit f5932fe
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 30 deletions.
31 changes: 17 additions & 14 deletions packages/block-editor/src/components/global-styles/color-panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { __, sprintf } from '@wordpress/i18n';
import ColorGradientControl from '../colors-gradients/control';
import { useColorsPerOrigin, useGradientsPerOrigin } from './hooks';
import { getValueFromVariable, TOOLSPANEL_DROPDOWNMENU_PROPS } from './utils';
import { setImmutably, omit } from '../../utils/object';
import { setImmutably } from '../../utils/object';
import { unlock } from '../../lock-unlock';

export function useHasColorPanel( settings ) {
Expand Down Expand Up @@ -712,19 +712,22 @@ export default function ColorPanel( {
onChange={ onChange }
panelId={ panelId }
>
{ items.map( ( item ) => (
<ColorPanelDropdown
key={ item.key }
{ ...omit( item, [ 'key' ] ) }
colorGradientControlSettings={ {
colors,
disableCustomColors: ! areCustomSolidsEnabled,
gradients,
disableCustomGradients: ! areCustomGradientsEnabled,
} }
panelId={ panelId }
/>
) ) }
{ items.map( ( item ) => {
const { key, ...restItem } = item;
return (
<ColorPanelDropdown
key={ key }
{ ...restItem }
colorGradientControlSettings={ {
colors,
disableCustomColors: ! areCustomSolidsEnabled,
gradients,
disableCustomGradients: ! areCustomGradientsEnabled,
} }
panelId={ panelId }
/>
);
} ) }
{ children }
</Wrapper>
);
Expand Down
7 changes: 6 additions & 1 deletion packages/block-editor/src/hooks/typography.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ import { FONT_SIZE_SUPPORT_KEY } from './font-size';
import { TEXT_ALIGN_SUPPORT_KEY } from './text-align';
import { cleanEmptyObject } from './utils';
import { store as blockEditorStore } from '../store';
import { omit } from '../utils/object';

function omit( object, keys ) {
return Object.fromEntries(
Object.entries( object ).filter( ( [ key ] ) => ! keys.includes( key ) )
);
}

const LETTER_SPACING_SUPPORT_KEY = 'typography.__experimentalLetterSpacing';
const TEXT_TRANSFORM_SUPPORT_KEY = 'typography.__experimentalTextTransform';
Expand Down
14 changes: 0 additions & 14 deletions packages/block-editor/src/utils/object.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,3 @@ export function uniqByProperty( array, property ) {
return seen.has( value ) ? false : seen.add( value );
} );
}

/**
* Helper to omit keys from a given object.
*
* @param {Object} object Object.
* @param {string[]} keys Keys to omit.
*
* @return {Object} Object without the omitted keys.
*/
export function omit( object, keys ) {
return Object.fromEntries(
Object.entries( object ).filter( ( [ key ] ) => ! keys.includes( key ) )
);
}
1 change: 0 additions & 1 deletion packages/components/src/custom-select-control/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ export default function CustomSelectControl( props ) {
<ul { ...menuProps } onKeyDown={ onKeyDownHandler }>
{ isOpen &&
items.map( ( item, index ) => (
// eslint-disable-next-line react/jsx-key
<li
key={ item.key }
{ ...getItemProps( {
Expand Down

0 comments on commit f5932fe

Please sign in to comment.