Skip to content

Commit 38a9678

Browse files
committed
Fix unlock for mobile
1 parent be443f4 commit 38a9678

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

packages/block-library/src/gallery/gap-styles.js

+15-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,17 @@ import {
1111
*/
1212
import { unlock } from '../lock-unlock';
1313

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

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

53+
if ( ! useStyleOverride ) {
54+
useStyleOverride = unlock( blockEditorPrivateApis ).useStyleOverride;
55+
}
56+
4357
useStyleOverride( {
4458
id: `gallery-gap-${ clientId }`,
4559
css: gap,

0 commit comments

Comments
 (0)