-
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
Stabilize isPreviewMode flag #66149
Stabilize isPreviewMode flag #66149
Conversation
Size Change: +96 B (+0.01%) Total Size: 1.81 MB
ℹ️ View Unchanged
|
c30246d
to
72f81d3
Compare
Flaky tests detected in 72f81d3. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/11355847467
|
…vate symbol within RichText block
e98aad3
to
7d80623
Compare
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
…etting when spreading the settings object
… defining a nested provider
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.
This is looking good to me. Thanks :)
* Introduce stable isPreviewMode key and deprecate __unstableIsPreviewMode * Expose stable isPreviewMode as registry values * Use isPreviewMode instead of __unstableIsPreviewMode when accessing the setting * Access isPreviewMode directly from getSettings instead of through private symbol within RichText block * Revert private isPreviewMode changes * Add __unstableIsPreviewMode getter within settings reducer * Remove all other __unstableIsPreviewMode definitions * Define deprecation setter with Object.defineProperty to avoid eager getting when spreading the settings object * Use WP version within deprecation note * Add deprecation notice when trying to set __unstableIsPreviewMode in updateSettings * Add test to assert deprecated getters are passed to sub registry when defining a nested provider * Move deprecated setter logic to __experimentalUpdateSettings
Why?
It's been almost three years since we introduced
__unstableIsPreviewMode
as a flag to indicate if the block is being rendered as part of the blocks list, block preview, pattern preview, etc. It's time to make it stable.I was motivated after Automattic/jetpack#39768 (comment).
How?
This PR adds
isPreviewMode
as a new default setting key and alongside__unstableIsPreviewMode
whenever it's used as a sub-registry value.Finally, I'm rewriting all internal usages of
__unstableIsPreviewMode
to the newisPreviewMode
flag.