Created
January 30, 2023 07:37
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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