Skip to content

Block Inspector: Margin bottom applied to BaseControls affects layout of some components #49796

Open

Description

@t-hamano

This issue summarizes a problem, as reported in #49520, where unintended margin bottom is applied to inner BaseControls components when the component is placed inside of the Block Inspector.

I first decided to access the public StoryBook page to find out which components encompass the BaseControls component.

I ran the following code in the browser console to apply margin-bottom when the BaseControls component was present and extract components with layout changes:

// If a BaseControl component is present in a StoryBook iframe document, apply a margin bottom to it.
const iFrame = document.getElementById('storybook-preview-iframe');
const doc = iFrame.contentDocument;
const baseControls = doc.querySelectorAll('.components-base-control');
if ( ! baseControls.length ) {
	console.log('No BaseControls component.');
} else {
	console.log('BaseControls component exists: ' + baseControls.length);
	doc.body.innerHTML += '<style>#root .components-base-control{margin-bottom: 24px!important;} .components-base-control{ border: 1px red solid;}</style>';
}

I then actually injected those components into the Block Inspector to check if the layout was actually broken. As a result, I found that the following components are affected.

Affected components

These components have an internal BaseControl component and are always affected.

AnglePickerControl

AnglePickerControl

ColorPicker

ColorPicker

CustomGradientPicker

CustomGradientPicker

DateTImePicker (TimePicker)

DateTimePicker

GradientPicker

GradientPicker

BorderBoxControl

BorderBoxControl

BoxControl

BoxControl

Affected, but the layout is not broken

The following components apply margin-bottom to the internal BaseControl component but do not affect the layout at the component level.

BorderControl

BorderControl

FontSizePicker

FontSizePicker

RangeControl

RangeControl

Components with children

Components that can have children, such as PlaceHolder, TabPanel, etc., are all affected if a component is specified whose children include a BaseControl component.

Placeholder

Placeholder

What is your proposed solution?

Realistically, I believe that it is difficult to address all cases. I think it would be better to add a margin-reset selector like the one mentioned in this comment, limited to those that cause layout breakdowns at the component level.

Activity

  1. self-assigned this
    on Apr 13, 2023
  2. added
    [Type] BugAn existing feature does not function as intended
    on Apr 13, 2023
  3. youknowriad commented on Dec 24, 2025

    @youknowriad
    Contributor

    I think @mirka removed the margin from most of these components. IS this issue still relevant?

  4. mirka commented on Dec 25, 2025

    @mirka
    Member

    I think this is about the bottom margin that Block Inspector explicitly adds, not the margins that used to be on the control components themselves. Related to #65191.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

CSS StylingRelated to editor and front end styles, CSS-specific issues.[Package] Block editor/packages/block-editor[Type] BugAn existing feature does not function as intended

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions