Inserter: Preview saved block on hover#4246
Conversation
My thought was an |
editor/components/inserter/group.js
Outdated
| ref={ bindReferenceNode( block.name ) } | ||
| tabIndex={ current === block.name || disabled ? null : '-1' } | ||
| disabled={ disabled } | ||
| onMouseEnter={ this.hoverBlock( ( block ) ) } |
editor/components/inserter/group.js
Outdated
| } | ||
| } | ||
|
|
||
| hoverBlock( block ) { |
There was a problem hiding this comment.
The function name doesn't seem entirely accurate. This is not the hover handler itself; it creates a hover handler. Maybe: createToggleBlockHover ?
Also: Maybe it's worthwhile to check this.props.onHover before returning anything here? That way, we could e.g. return null; and avoid creating new function references (i.e. forcing React to reconcile changing function handlers).
| @@ -1,3 +1,7 @@ | |||
| $content-height: 250px; | |||
There was a problem hiding this comment.
My understanding is these assigned variables are global to all stylesheets, and this seems like it might be a common name. Maybe worth prefixing to act as namespace if we want the variables?
blocks/library/code/index.js
Outdated
| example: { | ||
| content: ` | ||
| <?php | ||
| echo "Beep Beeb Boop"; |
There was a problem hiding this comment.
Personally I'd find this reasonable to inline in the sense that even stylistically this is something I'd have on one line:
example: {
content: '<?php echo "Beep Beep Boop"; ?>',
},3919ca3 to
f444541
Compare
|
I added the
|
blocks/library/code/index.js
Outdated
| }, | ||
|
|
||
| example: { | ||
| content: '<?php echo "Beep Beep Boop";?>', |
There was a problem hiding this comment.
Very minor: I'd expect a space before the closing ?>
There was a problem hiding this comment.
Minor: PHP Guidelines recommend single quotes:
If you’re not evaluating anything in the string, use single quotes.
| @@ -0,0 +1,39 @@ | |||
| /** | |||
| * External dependencie | |||
There was a problem hiding this comment.
Typo: "dependencie" -> "dependencies"
|
@jasmussen @youknowriad I think this might need a few more iterations, what do you think of enabling only for "saved blocks" initially? That provides immediate value and requires less consideration of dummy data since saved blocks, by their nature, don't need it. |
|
I think it's fine to start small and test. 👍 👍 |
|
Should I remove the "example" API for now? |
I don't mind retaining it but not documented. |
|
I updated this, it's now limited to the reusable blocks and I also updated the design of the inserter "blocks" by removing the margin in favor of a padding to avoid the flickering when we move the mouse between saved blocks. |
395053c to
24e0dfa
Compare
|
Can I have a final review here? |
|
@jasmussen I'm not able to reproduce the error. Do you know what kind of reusable block produces this error? |
|
I just left the office, I may not be able to reproduce at home, but it's an old installation with lots of reusable blocks created across different versions. I'm the same session I noticed a reusable block in the recent tab that was actually deleted. |
|
I was reliably reproducing this as well. |
|
Was the issue I noted in #4246 (review) addressed ?
|
|
@aduth The issue was not handled but not sure what can we do about it? Any ideas? Should we show the preview on the right of the inserter instead? cc @jasmussen |
|
The effect of the preview when the inserter opens upwards is a blinking effect where you hover over a saved block and the preview kicks in moving the hovered block upwards, and then it goes for a loop. Can we just show the preview above the inserter, instead of below it, when the inserter opens upwards? |
|
@jasmussen That's another issue, we probably can do what you suggest but it doesn't solve the "scrolling" issue if there's not enough space. |
|
Ah, understood. How about we solve this in two phases. For now, we decide that this is a desktop only enhancement, with no preview on mobile — hover doesn't work too well there anyway. And given that, we show the preview on the right instead of above or below. We can also make it smaller. |
|
Ok, I moved the preview to the right, I think it's better. |
2f68d7e to
67b89c8
Compare
|
I've been able to break it by creating a paragraph block, saving as reusable, selecting it on the editor canvas, then opening the inserter and hovering over it. The editor crashes with:
Should be easy to reproduce. |
67b89c8 to
e977dc4
Compare
|
This should be ready for a final review. |
|
@jasmussen I was seeing a few inconsistencies in the visual display of fonts, etc, that I think we should address. Might be worth applying default styles to a generic |
|
On which previewed blocks did you see these issues? |
|
@jasmussen Unfortunately, we can't use shadow dom because it doesn't work on Firefox and can't be polyfilled properly. |
(ノಠ益ಠ)ノ彡┻━┻ No worries, it was mostly a case of "it would be nice" :) |
|
It will look amazing as soon as we add |
1daee71 to
411f7d2
Compare
|
I'm thinking we can merge this right? |
|
@jasmussen we can use a class like |
|
I wonder if |










closes #4106
This PR tries to show a preview of the block to be inserted at the bottom of the inserter menu.
Ideas to improve the design are welcome.
I believe we could introduce a
sampleAttributesproperty for blocks to make this preview more compelling using the sample attributes.Maybe we could consider dropping the margins between the blocks in the inserter to avoid the flickering effect when moving from a block to another.