Describe the bug
Registered blocks' settings can be altered via JS hook blocks.registerBlockType. This can be used to limit alignment options for various default blocks. If you try to limit image block's align options, the default align settings are rendered with the new altered settings – you'll end up with two align UIs.
To reproduce
Steps to reproduce the behavior:
- Add JS file to theme "editor-gutenberg.js"
- Include it to Gutenberg
add_action('enqueue_block_editor_assets', function() {
wp_enqueue_script('my-gutenberg-scripts', get_stylesheet_directory_uri() . '/dist/scripts/editor-gutenberg.js', ['wp-i18n', 'wp-blocks', 'wp-dom-ready'], '', true);
});
- Filter out unwanted align options (ref: https://developer.wordpress.org/block-editor/developers/filters/block-filters/#blocks-registerblocktype)
wp.hooks.addFilter(
'blocks.registerBlockType',
'my-theme/filters',
function(settings, name) {
if (name === 'core/image') {
return lodash.assign({}, settings, {
supports: lodash.assign({}, settings.supports, {
align: ['wide'],
}),
});
}
return settings;
}
);
Expected behavior
Default alignment dropdown options are replaced with filtered ones.
Screenshots

(Two UIs for alignment)
Root of problem
Describe the bug
Registered blocks' settings can be altered via JS hook
blocks.registerBlockType. This can be used to limit alignment options for various default blocks. If you try to limit image block's align options, the default align settings are rendered with the new altered settings – you'll end up with two align UIs.To reproduce
Steps to reproduce the behavior:
Expected behavior
Default alignment dropdown options are replaced with filtered ones.
Screenshots

(Two UIs for alignment)
Root of problem