Skip to content
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

Show the default style variation if none provided #24217

Merged
merged 1 commit into from
Jul 27, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions packages/block-editor/src/components/block-styles/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,18 +110,21 @@ function BlockStyles( {
return null;
}

if ( ! type.styles && ! find( styles, 'isDefault' ) ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like you already knew it two years ago :) https://github.com/WordPress/gutenberg/pull/12519/files#r240045926

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, so what happened was that by setting [] as default for styles, the !type.styles was no longer true. 👍

styles.unshift( {
name: 'default',
label: _x( 'Default', 'block style' ),
isDefault: true,
} );
}

const activeStyle = getActiveStyle( styles, className );
const renderedStyles = find( styles, 'isDefault' )
? styles
: [
{
name: 'default',
label: _x( 'Default', 'block style' ),
isDefault: true,
},
...styles,
];

const activeStyle = getActiveStyle( renderedStyles, className );
return (
<div className="block-editor-block-styles">
{ styles.map( ( style ) => {
{ renderedStyles.map( ( style ) => {
const styleClassName = replaceActiveStyle(
className,
activeStyle,
Expand Down