-
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
Editor: Limit spotlight mode to the editor. #58817
Conversation
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 Unlinked AccountsThe following contributors have not linked their GitHub and WordPress.org accounts: @AndrewJDFerguson. Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases. 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. |
Size Change: +714 B (0%) Total Size: 1.71 MB
ℹ️ View Unchanged
|
Hi, @juanfra, I think we can also disable "Spotlight mode" mode via the block editor settings for previews. diff --git packages/block-editor/src/components/block-preview/index.js packages/block-editor/src/components/block-preview/index.js
index 0fb7f55b995..245d0ee4348 100644
--- packages/block-editor/src/components/block-preview/index.js
+++ packages/block-editor/src/components/block-preview/index.js
@@ -54,7 +54,11 @@ export function BlockPreview( {
[]
);
const settings = useMemo(
- () => ( { ...originalSettings, __unstableIsPreviewMode: true } ),
+ () => ( {
+ ...originalSettings,
+ focusMode: false, // Disable "Spotlight mode".
+ __unstableIsPreviewMode: true,
+ } ),
[ originalSettings ]
);
const renderedBlocks = useMemo(
@@ -117,6 +121,7 @@ export function useBlockPreview( { blocks, props = {}, layout } ) {
() => ( {
...originalSettings,
styles: undefined, // Clear styles included by the parent settings, as they are already output by the parent's EditorStyles.
+ focusMode: false, // Disable "Spotlight mode".
__unstableIsPreviewMode: true,
} ),
[ originalSettings ]
|
Flaky tests detected in 11fdd14. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/7903028126
|
Thanks @Mamaduka ✨ That's indeed a way better approach, I've updated the PR |
() => ( { | ||
...originalSettings, | ||
focusMode: false, // Disable "Spotlight mode". | ||
__unstableIsPreviewMode: true, | ||
} ), |
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.
I think this change in the StyleBook
component isn't required; these settings
aren't passed into BlockEditorProvider
.
Side note: The component doesn't really need the complete set of settings. They're passed to StyleBookBody
, which only uses settings.styles
. But this is unrelated to the fix here.
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.
Thank you, @juanfra! The fix works as expected!
Thank you, George! Oh snap, I just realized there's a new way to credit the changes by adding the people involved in the merge commit, and I didn't do that. Sorry 🙏 |
@juanfra As this fixed a bug on the WP 6.5 board I have adde the appropriate label to ensure it gets backported. If that is not correct please let me know. |
* Limit spotlight mode to the editor. * Revert "Limit spotlight mode to the editor." This reverts commit b8d4754. * Disable "Spotlight mode" for block previews. * Revert non-required changes.
I just manually cherry-picked this PR to the cherry-pick-wp-6-5-beta-3 branch to get it included in the next release. |
Instead of explicitly passing this setting, I wonder if |
* Limit spotlight mode to the editor. * Revert "Limit spotlight mode to the editor." This reverts commit b8d4754. * Disable "Spotlight mode" for block previews. * Revert non-required changes.
What?
Enabling spotlight mode in the editor greyed out every block representation outside the editor (preview in the inserter, patterns in the inserter, etc).
Setting "Spotlight mode" to false when calling the block previewer.
Fixes #42660
Why?
Spotlight mode should be limited to the editor content. When affecting the inserter and other previews, it makes it look like a defect.
How?
Setting "Spotlight mode" to false when calling the block previewer.
Testing Instructions
Post editor
Site editor
Screenshots or screencast
PR-fix-42660.mov