PluginProbe
SureForms – Contact Form Builder, AI Forms, Payment Form, Survey & Quiz / 2.12.8
SureForms – Contact Form Builder, AI Forms, Payment Form, Survey & Quiz v2.12.8
2.12.8 2.12.7 2.12.6 2.12.5 2.12.4 2.12.3 2.12.2 2.12.1 2.12.0 2.11.1 2.11.0 2.10.1 2.10.0 2.9.1 2.9.0 2.8.2 2.8.1 2.7.0 2.7.1 2.8.0 trunk 0.0.10 0.0.11 0.0.12 0.0.13 All 98 releases
← All changes | modules/quick-action-sidebar/components/blocks.js +7 -5 2.12.3 → 2.12.8 View file →
@@ -5,8 +5,12 @@
5 5 import { createBlock, getBlockTypes } from '@wordpress/blocks';
6 6 import DraggableBlock from './draggable-block';
7 7 import DragAndDropComponent from './move-up-down';
8 8
9 +// Stable reference so `useSelect` doesn't return a fresh empty array on every
10 +// call when no allowed blocks are resolved, which would trigger needless re-renders.
11 +const EMPTY_ALLOWED_BLOCKS = [];
12 +
9 13 const Blocks = ( {
10 14 defaultAllowedQuickSidebarBlocks,
11 15 updateDefaultAllowedQuickSidebarBlocks,
12 16 saveOptionToDatabase,
@@ -21,19 +25,17 @@
21 25 } = useSelect( ( select ) => {
22 26 const blockEditor = select( 'core/block-editor' );
23 27 const { index } = blockEditor.getBlockInsertionPoint();
24 28 const clientId = blockEditor.getSelectedBlockClientId();
25 - const rootClientId = blockEditor.getBlockRootClientId(
26 - getSelectedBlockClientId
27 - );
29 + const rootClientId = blockEditor.getBlockRootClientId( clientId );
28 30 const allowedBlocks = blockEditor.getAllowedBlocks( clientId );
29 31 return {
30 32 blockInsertionPoint: index,
31 33 getBlockRootClientId: rootClientId,
32 34 getSelectedBlockClientId: clientId,
33 - getSelectedBlockAllowedBlocks: allowedBlocks || [],
35 + getSelectedBlockAllowedBlocks: allowedBlocks || EMPTY_ALLOWED_BLOCKS,
34 36 };
35 - } );
37 + }, [] );
36 38 const srfmBlocks = blocks.filter( ( block ) => {
37 39 return defaultAllowedQuickSidebarBlocks.includes( block.name );
38 40 } );
39 41 const create = ( name ) => {