From 1ec9251790add7fb679cfdb4aada9b785c898710 Mon Sep 17 00:00:00 2001 From: George Mamadashvili Date: Tue, 21 May 2024 11:43:20 +0400 Subject: [PATCH 1/2] Block Editor: Unlock private setting keys at the file level --- .../components/provider/use-block-editor-settings.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/packages/editor/src/components/provider/use-block-editor-settings.js b/packages/editor/src/components/provider/use-block-editor-settings.js index 2a9ecf6073248..2917c6905e3f0 100644 --- a/packages/editor/src/components/provider/use-block-editor-settings.js +++ b/packages/editor/src/components/provider/use-block-editor-settings.js @@ -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. * @@ -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 = { @@ -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 ) => @@ -340,8 +340,6 @@ function useBlockEditorSettings( settings, postType, postId, renderingMode ) { setIsInserterOpened, sectionRootClientId, globalStylesData, - globalStylesDataKey, - selectBlockPatternsKey, ] ); } From ade98bd803df7a439754af7843c77723e23f5b31 Mon Sep 17 00:00:00 2001 From: George Mamadashvili Date: Tue, 21 May 2024 11:59:44 +0400 Subject: [PATCH 2/2] Feedback --- .../block-editor/src/components/colors-gradients/control.js | 6 +----- .../src/components/global-styles/color-panel.js | 6 ++---- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/packages/block-editor/src/components/colors-gradients/control.js b/packages/block-editor/src/components/colors-gradients/control.js index e820bf7328488..88b33379e04de 100644 --- a/packages/block-editor/src/components/colors-gradients/control.js +++ b/packages/block-editor/src/components/colors-gradients/control.js @@ -21,6 +21,7 @@ import { import { useSettings } from '../use-settings'; import { unlock } from '../../lock-unlock'; +const { Tabs } = unlock( componentsPrivateApis ); const colorsAndGradientKeys = [ 'colors', 'disableCustomColors', @@ -106,11 +107,6 @@ function ColorGradientControlInner( { ); - // 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 ( ( @@ -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 (