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

Try uncollapsing margins on the columns block. #8283

Merged
merged 2 commits into from
Aug 1, 2018
Merged
Changes from 1 commit
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
7 changes: 6 additions & 1 deletion core-blocks/columns/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,17 @@
}
}

// Flex container margins do not collapse: https://www.w3.org/TR/css-flexbox-1/#flex-containers.
// This block has flex container children. Flex container margins do not collapse: https://www.w3.org/TR/css-flexbox-1/#flex-containers.
// Therefore, let's at least not add any additional margins here.
// The goal is for the editor to look more like the front-end.
.editor-block-list__layout .editor-block-list__block[data-type="core/columns"] > .editor-block-list__block-edit,
.editor-block-list__layout .editor-block-list__block[data-type="core/column"] > .editor-block-list__block-edit {
margin-top: 0;
margin-bottom: 0;

// This uncollapses margins on this parent container.
padding-top: 1px;
Copy link
Member

Choose a reason for hiding this comment

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

Would 0.1px be a better value here? While it's not valid in the sense of a fraction of a pixel, it achieves the same effect while not having a visual difference (since it will round to 0).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the review, forgot to mention that before.

A better solution might exist in the process outlined below: #8283 (comment)

I pushed a fix to use the 0.1px as you suggested. Because although it had visual side effects on the Classic Block toolbar on retina screens (the rounding math glitched out every once in a while causing flickering when scrolling), it doesn't appear to have any side effects here.

However a different approach is to simply accept that flex containers margins do not collapse and stop compensating for it. That is — we don't need to prevent the parent block margins from collapsing (can remove the padding hack), but we also remove these two lines:

https://github.com/WordPress/gutenberg/blob/master/packages/editor/src/components/block-list/style.scss#L130

The net result is this:

screen shot 2018-07-31 at 10 19 20

GIF:

no compensation

As you can see the margins on paragraphs inside are now doubled before and after, because we don't compensate. We probably want to do this as part of #8283 (comment), depending on what you think of that.

padding-bottom: 1px;
}

.wp-block-columns {
Expand Down