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

Hide the columns count control on empty columns block #16476

Merged
merged 2 commits into from
Jul 15, 2019
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
11 changes: 7 additions & 4 deletions packages/block-library/src/columns/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,14 @@ export function ColumnsEdit( {
[ `are-vertically-aligned-${ verticalAlignment }` ]: verticalAlignment,
} );

// The template selector is shown when we first insert the columns block (count === 0).
// or if there's no template available.
// The count === 0 trick is useful when you use undo/redo.
const showTemplateSelector = ( count === 0 && ! forceUseTemplate ) || ! template;

return (
<>
{ template && (
{ ! showTemplateSelector && (
Copy link
Member

Choose a reason for hiding this comment

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

Alternatively, I wonder what it is about choosing columns that causes the issue in the first place. If someone wanted to skip the layout selection and just start setting columns (assuming of an equal width), why prevent them?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah I'm not sure what. I decided to remove the selector not only because of the bug because based on the previous check here. I assumed that removing the inspector controls was an intentional behavior.

<>
<InspectorControls>
<PanelBody>
Expand Down Expand Up @@ -170,9 +175,7 @@ export function ColumnsEdit( {
setForceUseTemplate( true );
} }
__experimentalAllowTemplateOptionSkip
// setting the template to null when the inner blocks
Copy link
Member

Choose a reason for hiding this comment

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

Seems like this comment is still valid?

// are empty allows to reset to the placeholder state.
template={ count === 0 && ! forceUseTemplate ? null : template }
template={ showTemplateSelector ? null : template }
templateLock="all"
allowedBlocks={ ALLOWED_BLOCKS } />
</div>
Expand Down