Skip to content

Commit

Permalink
try: Move block toolbar below block contents
Browse files Browse the repository at this point in the history
Fix #3976
  • Loading branch information
tofumatt committed Oct 10, 2018
1 parent 1349d23 commit 20043f3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
4 changes: 4 additions & 0 deletions packages/block-library/src/classic/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,10 @@ div[data-type="core/freeform"] .editor-block-contextual-toolbar + div {
width: auto;
margin: 0 #{ -$block-padding };
position: sticky;
position: absolute;
z-index: z-index(".freeform-toolbar");
top: $block-padding;
top: 0;
transform: translateY(-$block-padding);

// On mobile, toolbars go edge to edge.
Expand Down Expand Up @@ -211,7 +213,9 @@ div[data-type="core/freeform"] .editor-block-contextual-toolbar + div {
float: right;
margin-right: -$block-side-ui-clearance - $border-width;
transform: translateY(-#{ $block-padding - $border-width });
position: absolute;
top: $block-padding;
top: 0;

.editor-block-toolbar {
border: none;
Expand Down
2 changes: 1 addition & 1 deletion packages/editor/src/components/block-list/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,6 @@ export class BlockListBlock extends Component {
isHidden={ ! ( isHovered || isSelected ) || hoverArea !== 'left' }
/>
) }
{ shouldShowContextualToolbar && <BlockContextualToolbar /> }
{ isFirstMultiSelected && (
<BlockMultiControls rootClientId={ rootClientId } />
) }
Expand Down Expand Up @@ -546,6 +545,7 @@ export class BlockListBlock extends Component {
) }
{ !! error && <BlockCrashWarning /> }
</IgnoreNestedEvents>
{ shouldShowContextualToolbar && <BlockContextualToolbar /> }
{ showEmptyBlockSideInserter && (
<Fragment>
<div className="editor-block-list__side-inserter">
Expand Down
17 changes: 11 additions & 6 deletions packages/editor/src/components/block-list/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
@include break-small() {
padding-left: $block-container-side-padding;
padding-right: $block-container-side-padding;
position: relative;
}

// Don't add side padding for nested blocks.
Expand Down Expand Up @@ -726,7 +727,8 @@
*/

.editor-block-list__block .editor-block-contextual-toolbar {
position: sticky;
// position: sticky;
position: absolute;
z-index: z-index(".editor-block-contextual-toolbar");
white-space: nowrap;
text-align: left;
Expand Down Expand Up @@ -799,12 +801,15 @@
transform: translateY(-$block-toolbar-height -$block-padding -$border-width);

// IE11 does not support `position: sticky`.
@supports (position: sticky) {
position: sticky;
// @supports (position: sticky) {
// position: sticky;

// Compensate for translate, so the sticky sticks to the top.
top: $block-toolbar-height + $block-padding;
}
// // Compensate for translate, so the sticky sticks to the top.
// top: $block-toolbar-height + $block-padding;
// }

position: absolute;
top: 0;

// This is an important one. Because the toolbar is sticky, it's part of the flow.
// It behaves as relative, in other words, until it reaches an edge and then behaves as fixed.
Expand Down

0 comments on commit 20043f3

Please sign in to comment.