Skip to content

Commit

Permalink
Fix unlock for mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix committed Sep 15, 2023
1 parent be443f4 commit 38a9678
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion packages/block-library/src/gallery/gap-styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,17 @@ import {
*/
import { unlock } from '../lock-unlock';

const { useStyleOverride } = unlock( blockEditorPrivateApis );
// TODO: The following line should have been:
//
// const unlockedApis = unlock( blockEditorPrivateApis );
//
// But there are hidden circular dependencies in RNMobile code, specifically in
// certain native components in the `components` package that depend on
// `block-editor`. What follows is a workaround that defers the `unlock` call
// to prevent native code from failing.
//
// Fix once https://github.com/WordPress/gutenberg/issues/52692 is closed.
let useStyleOverride;

export default function useGapStyles( { blockGap, clientId } ) {
// --gallery-block--gutter-size is deprecated. --wp--style--gallery-gap-default should be used by themes that want to set a default
Expand Down Expand Up @@ -40,6 +50,10 @@ export default function useGapStyles( { blockGap, clientId } ) {
gap: ${ gapValue }
}`;

if ( ! useStyleOverride ) {
useStyleOverride = unlock( blockEditorPrivateApis ).useStyleOverride;
}

useStyleOverride( {
id: `gallery-gap-${ clientId }`,
css: gap,
Expand Down

0 comments on commit 38a9678

Please sign in to comment.