Skip to content

Commit

Permalink
Block Editor: Unlock private setting keys at the file level (WordPres…
Browse files Browse the repository at this point in the history
…s#61813)

* Block Editor: Unlock private setting keys at the file level
* Feedback

Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: ellatrix <ellatrix@git.wordpress.org>
  • Loading branch information
3 people authored and patil-vipul committed Jun 17, 2024
1 parent 52458dd commit 32e7543
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
import { useSettings } from '../use-settings';
import { unlock } from '../../lock-unlock';

const { Tabs } = unlock( componentsPrivateApis );
const colorsAndGradientKeys = [
'colors',
'disableCustomColors',
Expand Down Expand Up @@ -106,11 +107,6 @@ function ColorGradientControlInner( {
</div>
);

// Unlocking `Tabs` too early causes the `unlock` method to receive an empty
// object, due to circular dependencies.
// See https://github.com/WordPress/gutenberg/issues/52692
const { Tabs } = unlock( componentsPrivateApis );

return (
<BaseControl
__nextHasNoMarginBottom
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ const popoverProps = {
shift: true,
};

const { Tabs } = unlock( componentsPrivateApis );

const LabeledColorIndicators = ( { indicators, label } ) => (
<HStack justify="flex-start">
<ZStack isLayered={ false } offset={ -8 }>
Expand Down Expand Up @@ -207,10 +209,6 @@ function ColorPanelDropdown( {
panelId,
} ) {
const currentTab = tabs.find( ( tab ) => tab.userValue !== undefined );
// Unlocking `Tabs` too early causes the `unlock` method to receive an empty
// object, due to circular dependencies.
// See https://github.com/WordPress/gutenberg/issues/52692
const { Tabs } = unlock( componentsPrivateApis );

return (
<ToolsPanelItem
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ const BLOCK_EDITOR_SETTINGS = [
'__experimentalArchiveTitleNameLabel',
];

const { globalStylesDataKey, selectBlockPatternsKey, reusableBlocksSelectKey } =
unlock( privateApis );

/**
* React hook used to compute the block editor settings to use for the post editor.
*
Expand Down Expand Up @@ -256,8 +259,6 @@ function useBlockEditorSettings( settings, postType, postId, renderingMode ) {
}, [ settings.allowedBlockTypes, hiddenBlockTypes, blockTypes ] );

const forceDisableFocusMode = settings.focusMode === false;
const { globalStylesDataKey, selectBlockPatternsKey } =
unlock( privateApis );

return useMemo( () => {
const blockEditorSettings = {
Expand All @@ -283,8 +284,7 @@ function useBlockEditorSettings( settings, postType, postId, renderingMode ) {
? patterns
: undefined;
},
[ unlock( privateApis ).reusableBlocksSelectKey ]:
__experimentalReusableBlocksSelect,
[ reusableBlocksSelectKey ]: __experimentalReusableBlocksSelect,
__experimentalBlockPatternCategories: blockPatternCategories,
__experimentalUserPatternCategories: userPatternCategories,
__experimentalFetchLinkSuggestions: ( search, searchOptions ) =>
Expand Down Expand Up @@ -340,8 +340,6 @@ function useBlockEditorSettings( settings, postType, postId, renderingMode ) {
setIsInserterOpened,
sectionRootClientId,
globalStylesData,
globalStylesDataKey,
selectBlockPatternsKey,
] );
}

Expand Down

0 comments on commit 32e7543

Please sign in to comment.