-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
(edit-post)(preferences)(workaround) Keep openPanels
and inactivePanels preferences in the
core/edit-post` scope to satisfy existing consumers
#57988
Conversation
…ences in the `core/edit-post` scope for backwards compatibility
Size Change: +7 B (0%) Total Size: 1.7 MB
ℹ️ View Unchanged
|
Flaky tests detected in 56d7e5f. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/7577237840
|
Heads up for @carolinan @afercia @aristath on the yoast side of things! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for getting this PR up so quickly @fullofcaffeine!
I imagine there's a couple of contributing factors to Yoast breaking in this way:
- The assumption that consumers would be using the isEditorPanelOpened selector instead of accessing the preferences store directly. It looks like Editor: Move the panel visibility state from the edit-post to the editor package #57012 from @youknowriad was intended to ensure backwards compat for that selector, so it sounds like we've been assuming that's what consumers were using?
- That Yoast wasn't using optional chaining in its handling, whereas Gutenberg uses
openPanels?.includes( panelName );
It'd be good to confirm with @youknowriad about what the right approach for consumers should be here. But for now, this PR resolves the issue for me while running Yoast, and updating the open panels preferences is still working nicely, so this LGTM for now. I suspect Yoast will still need to update their code to ensure things work smoothly in the future.
I'll just CC @talldan here, too, since he's done a lot of work on preferences.
Before | After |
---|---|
I'm not sure about this fix, as while it stops the fatal error happening, the plugin is still broken and they won't necessarily know there's something wrong until they discover the user facing issue. (edit: though I guess if something needs to ship quickly this would be ok as a short term solution that we remove later) @andrewserong makes some good points. A recommendation to yoast would be to use the In terms of remediation for the backwards compatibility, I have mixed feelings about it. One solution would be to add some kind of proxy in place so that |
Here's a quickly thrown together branch showing the idea, I haven't tested whether it works or anything, but it shows how the API might work from a code point of view: One issue is that not every preference has been migrated, so for some of them it doesn't make sense to proxy. I'm not sure if the plan is to migrate every preference for 6.5. If not, this is probably where my idea might fall short. We could make the API granular enough so that it's per-preference, but that starts getting more complicated. |
Interesting, I didn't think that this was necessary but folks are apparently accessing these preferences directly. I kind agree with @talldan that this is not the right fix, we should instead make sure that |
openPanels
and inactivePanels preferences in the
core/edit-post` scope to satisfy existing consumersopenPanels
and inactivePanels preferences in the
core/edit-post` scope to satisfy existing consumers
Thanks for the feedback! That's a good point. I knew this smelled in this sense, but I didn't know enough about the change and code around it to get a proper fix up. Hence why I added this part to the description:
|
Closed in favor of #58016. |
What?
Keep the
openPanels
andinactivePanels
preferences in thecore/edit-post
scope - in addition to thecore
scope (to which they were moved in #57529) to keep the old interface that some consumers expect.Why?
Consumers might still expect these preferences to be found in
core/edit-post
scope. If the setting is not found, it could cause an unhandled exception and break the functionality. This is the case with Yoast - it consumes theopenPanels
preference like this:Since
select('core/preferences').get('core/edit-post', 'openPanels')
returnsundefined
after the recent changes, the.includes('yoast-seo/document-panel')
call leads to aTypeError
, disrupting the code flow and causing issues with the Yoast metabox rendering (since nothing is guarding against that, i.e optional chaining). See the screenshot down below.How?
This workaround keeps the
openPanels
property in the object passed as an argument to thedispatch( preferencesStore ).setDefaults( 'core/edit-post', ... )
call. @andrewserong also suggested defining the relatedinactivePanels
property too.This PR is meant to illustrate a temporary workaround that fixes the Yoast issue and also to trigger a discussion about a definitive solution. Some questions come to mind:
core
scope incore/edit-post
? See editorMode and hiddenBlockTypes.Testing Instructions
trunk
and build Gutenberg from it, install/sync this version to the site;Screenshots or screencast
trunk