fix(editor): Ensure reliable unregistration of block variations#182
Conversation
Introduces a mechanism to wait for target blocks to be fully registered in the editor store before attempting to unregister their variations. This prevents potential issues where variations might not be unregistered if blocks are not yet available when `domReady` fires. Additionally, this change refactors block style and variation unregistration into dedicated helper functions for improved code organization and readability.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 788473f. Configure here.
| unsubscribe(); | ||
| callback(); | ||
| }); | ||
| }; |
There was a problem hiding this comment.
All-or-nothing block check prevents partial unregistration and leaks subscription
Medium Severity
whenBlocksRegistered requires ALL blocks in allowedBlocksVariations to be registered before unregistering variations for ANY of them. Since settings are filterable via bff_editor_custom_settings, if any configured block is never registered (e.g., from a deactivated plugin or unsupported editor context), the subscribe listener persists for the entire session — firing areBlocksReady() on every single data store state change — and no variations are ever unregistered for any block. The previous code handled each block independently.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 788473f. Configure here.
|
@firestar300 : a faire sur BFF |
|


Introduces a mechanism to wait for target blocks to be fully registered in the editor store before attempting to unregister their variations. This prevents potential issues where variations might not be unregistered if blocks are not yet available when
domReadyfires.Additionally, this change refactors block style and variation unregistration into dedicated helper functions for improved code organization and readability.
Note
Medium Risk
Changes Gutenberg editor initialization logic and renames the injected global settings constant; issues here could break style/variation unregistration or cause JS errors in the editor.
Overview
Improves reliability of Gutenberg block variation filtering by waiting until target blocks are registered (via
@wordpress/datasubscribe+getBlockType) before unregistering disallowed variations.Refactors editor setup into helper functions, fixes disabled block style unregistration to handle multiple styles per block, and renames the injected settings global from
BFFEditorSettingstoBEAPI_EDITOR_SETTINGS(PHP inline settings + JS usage).Reviewed by Cursor Bugbot for commit 788473f. Bugbot is set up for automated code reviews on this repo. Configure here.