Skip to content

fix(editor): Ensure reliable unregistration of block variations#182

Merged
firestar300 merged 2 commits into
mainfrom
fix/editor-script
May 18, 2026
Merged

fix(editor): Ensure reliable unregistration of block variations#182
firestar300 merged 2 commits into
mainfrom
fix/editor-script

Conversation

@firestar300

@firestar300 firestar300 commented May 18, 2026

Copy link
Copy Markdown
Contributor

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.


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/data subscribe + 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 BFFEditorSettings to BEAPI_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.

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.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ 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.

Comment thread src/js/common/editor.js
unsubscribe();
callback();
});
};

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 788473f. Configure here.

@francoistibo

Copy link
Copy Markdown
Contributor

@firestar300 : a faire sur BFF

@firestar300

Copy link
Copy Markdown
Contributor Author

@firestar300 : a faire sur BFF

BeAPI/beapi-frontend-framework#498

@firestar300 firestar300 merged commit b5f7e93 into main May 18, 2026
1 check passed
@firestar300 firestar300 deleted the fix/editor-script branch May 18, 2026 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants