Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The editor settings object doesn't work properly #31701

Closed
5n opened this issue May 11, 2021 · 2 comments
Closed

The editor settings object doesn't work properly #31701

5n opened this issue May 11, 2021 · 2 comments

Comments

@5n
Copy link

5n commented May 11, 2021

Description

Related #31027 (WordPress/wordpress-develop#1118), #31587, and so on.
Function 'getSettings' doesn't store the settings passed to the block editor.

Step-by-step reproduction instructions

  1. Install and activate Gutenberg plugin.
  2. Install and activate Twenty Twenty-One or TT1 Blocks.
  3. Upload and activate sample-settings plugin.
  4. Go to edit post page ('post', 'page', or custom post like 'wp_template').
  5. Click and add Sample Settings block.
  6. Check the value of custom parameter displayed on sidebar and console log.

Expected behaviour

'sample setting value'

Actual behaviour

undefined

Screenshots or screen recording (optional)

getsettings1
getsettings2

Code snippet (optional)

PHP:

function add_sample_block_editor_settings($settings) {
  $settings['sampleSetting'] = 'sample setting value';
  return $settings;
}
add_filter('block_editor_settings', 'add_sample_block_editor_settings');

'block_editor_settings' -> 'block_editor_settings_all' since 5.8.0.

JSX:

import { store as blockEditorStore } from "@wordpress/block-editor";
import { useSelect, select } from "@wordpress/data";

export default function Edit() {
  const sampleSetting = useSelect((select) => {
    const { getSettings } = select(blockEditorStore);
    return getSettings()?.sampleSetting;
  }, []);
}

WordPress information

  • WordPress version: 5.7.1
  • Gutenberg version: 10.5.4
  • Are all plugins except Gutenberg deactivated? Yes
  • Are you using a default theme (e.g. Twenty Twenty-One)? Yes

Device information

  • Device: Desktop
  • Operating system: Windows 10
  • Browser: Google Chrome 90.0
@youknowriad
Copy link
Contributor

youknowriad commented May 11, 2021

Hi, thanks for the issue.

This is not a bug, this is actually the intended behavior. All editor settings don't make sense in the "block-editor" store which is basically something generic enough that can be used in any block editor instance (not WP or post editor specific)

@5n
Copy link
Author

5n commented May 11, 2021

I see.
Thanks!

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

No branches or pull requests

2 participants