-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
BlockStylesPanel: should only be displayed in default editing mode #69260
base: trunk
Are you sure you want to change the base?
BlockStylesPanel: should only be displayed in default editing mode #69260
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 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. |
Note: The failing test cases are not related to the changeset introduced in this PR. |
I am not familiar enough with the different editing modes to know wether this was intentionally left out. |
If we add a We might want to check if the block is in content regardless of the eitingmode. Does @Mamaduka know of any suitable hooks? |
I somehow missed this crucial detail at first. After searching for relevant hooks without success, I tried the following approach, which works as expected: const isWithinContentBlock = useSelect(
( select ) => {
const { getBlockParents, getBlockName } =
select( blockEditorStore );
const parents = getBlockParents( clientId );
return parents.some(
( parent ) => getBlockName( parent ) === 'core/post-content'
);
},
[ clientId ]
); Please let me know what your thoughts are. Edit: We might need to use |
de337e3
to
daeba11
Compare
What?
Closes #69238
This PR adds logic to prevent rendering
BlockStylesPanel
when the editing mode is not set todefault
. This fixes the core problem that causes theBlock Style Variations
to be displayed for theHeading Block
when viewed fromDocument Outline
, as described in the parent issue.Why?
Since other settings within the Block Settings are not displayed in this scenario, showing the Block Style Variations is unnecessary, especially if they cannot be saved.
How?
Similar to how the other Panels such as
Color
,Typography
,Dimensions
,Border
, andBackgroundImage
are only rendered when theEditing Mode
is set todefault
, this PR implements the same condition for rendering theBlockStylesPanel
to keep the code logic consistent and achieve the desired outcome.Ref.
gutenberg/packages/block-editor/src/hooks/style.js
Lines 345 to 347 in 4680ff3
Testing Instructions
Block Style Variations
for theHeading Block
.Template
.Screenshots