Skip to content

Commit

Permalink
Block: fix invalid block scrim overflowing toolbar on mobile (#9473)
Browse files Browse the repository at this point in the history
* Fix invalid block scrim overflowing toolbar on mobile

On small screens the invalid block scrim overflows a block’s dropdown menu / toolbar, which is positioned beneath the block.

* Clarify variable.

* Tweak block warning quite a bit.

This commit changes the layout and design of the block warning a bit.

It is no longer obscuring content, and the scrim is lighter.

* Also fix for nested blocks.

* Restore the full border.
  • Loading branch information
johngodley committed Sep 13, 2018
1 parent b43f318 commit 851aec0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 11 deletions.
6 changes: 3 additions & 3 deletions packages/editor/src/components/block-list/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -539,13 +539,13 @@ export class BlockListBlock extends Component {
<BlockHtml clientId={ clientId } />
) }
{ ! isValid && [
<div key="invalid-preview">
{ getSaveElement( blockType, block.attributes ) }
</div>,
<BlockInvalidWarning
key="invalid-warning"
block={ block }
/>,
<div key="invalid-preview">
{ getSaveElement( blockType, block.attributes ) }
</div>,
] }
</BlockCrashBoundary>
{ shouldShowMobileToolbar && (
Expand Down
29 changes: 21 additions & 8 deletions packages/editor/src/components/block-list/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@
&.has-warning .editor-block-list__block-edit::after {
content: "";
position: absolute;
background-color: rgba($light-gray-100, 0.8);
background-color: rgba($light-gray-100, 0.4);

top: -$block-padding;
bottom: -$block-padding;
Expand All @@ -321,6 +321,14 @@
}
}

&.has-warning.is-selected .editor-block-list__block-edit::after {
bottom: ( $block-toolbar-height - $block-padding - $border-width );

@include break-small() {
bottom: -$block-padding;
}
}

// Appender
&.is-typing .editor-block-list__empty-block-inserter,
&.is-typing .editor-block-list__side-inserter {
Expand Down Expand Up @@ -1067,17 +1075,22 @@

.editor-block-list__block .editor-warning {
z-index: z-index(".editor-warning");
position: absolute;
top: -$block-padding - $border-width;
right: -$parent-block-padding - $border-width;
left: -$parent-block-padding - $border-width;
position: relative;

// Position for nested blocks
// Stretch the warning edge to edge.
margin-left: -$parent-block-padding - $border-width;
margin-right: -$parent-block-padding - $border-width;

// Stretch the warning less in nested contexts.
.editor-block-list__block & {
right: -$block-padding - $border-width;
left: -$block-padding - $border-width;
margin-left: -$block-padding - $border-width;
margin-right: -$block-padding - $border-width;
}

// Pull the warning upwards to the edge, and add a negative bottom margin to compensate.
margin-bottom: -$block-padding - $border-width;
transform: translateY(-$block-padding - $border-width);

// Bigger padding on mobile where blocks are edge to edge.
padding: 10px $parent-block-padding;
@include break-small() {
Expand Down

0 comments on commit 851aec0

Please sign in to comment.