Skip to content

Commit

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

Co-authored-by: Mamaduka <[email protected]>
Co-authored-by: ellatrix <[email protected]>
  • Loading branch information
3 people authored May 21, 2024
1 parent 0f68078 commit 81c0cd3
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

1 comment on commit 81c0cd3

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in 81c0cd3.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/9171885096
📝 Reported issues:

Please sign in to comment.