Skip to content

Instantly share code, notes, and snippets.

@bjorn2404
Created January 30, 2023 07:37
Show Gist options
  • Save bjorn2404/50b3277c03d7a95d6a185f95c5025f6d to your computer and use it in GitHub Desktop.
Save bjorn2404/50b3277c03d7a95d6a185f95c5025f6d to your computer and use it in GitHub Desktop.
Gutenberg panel status in v6+ to solve: select( 'core/edit-post' ).getPreference is deprecated since version 6.0. Please use select( 'core/preferences' ).get instead.
/**
* Didn't find much documentation on how to fix this issue
*
* This pull request made the panels change: https://github.com/WordPress/gutenberg/commit/9a195fca8e0a23af1605830b4128edb116a4964a
*/
// Instead of using this approach to get a single panel status:
const addressPanelStatus = select( 'core/edit-post' ).getPreference( 'panels' )['cardinal-locator-location-address/location-address-panel'];
// Get all the open panels and use a simple indexOf. Ex:
const openPanels = select( 'core/preferences' ).get( 'core/edit-post', 'openPanels' );
const addressPanelStatus = openPanels.indexOf( 'cardinal-locator-location-address/location-address-panel' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment