FIX: Only add inserters in between blocks (not at end)#3485
FIX: Only add inserters in between blocks (not at end)#3485ephox-mogran wants to merge 1 commit intomasterfrom
Conversation
| onSelectionStart={ this.onSelectionStart } | ||
| onShiftSelection={ this.onShiftSelection } | ||
| />, | ||
| <VisualEditorSiblingInserter |
There was a problem hiding this comment.
Because we are doing a flatmap, we could also just concat to the array of the block with either an empty array (when at last position), or an array containing this inserter. However, if you're happy with this && approach, then it should be fine.
There was a problem hiding this comment.
You can also simplify this code by removing the line before flatmap call and moving the Inserter to the first place in the array, in effect always prepend to the existing block.
There was a problem hiding this comment.
True. That's probably better. Is there any reason that the SiblingInserter isn't added when the default "Write Your Story" block is there?
There was a problem hiding this comment.
It looks like the Write Your Story block isn't a real block but only a placeholder.
Yes, I can confirm this. I inspected Redux state. When you click on Write Your Story, a new block is created for you.
gziolo
left a comment
There was a problem hiding this comment.
As suggested in https://github.com/WordPress/gutenberg/pull/3485/files#r151040721, we can simplify this solution a bit. Otherwise, it works as advertised. Nice 👍
| onShiftSelection={ this.onShiftSelection } | ||
| />, | ||
| <VisualEditorSiblingInserter | ||
| index < blocks.length - 1 && <VisualEditorSiblingInserter |
There was a problem hiding this comment.
Lack of parentheses make this a bit ambiguous (similar to no-mixed-operators). Is < considered before or after the subtraction (index < blocks.length)? Is subtraction including the element (1 && <VisualEditorSiblingInserter)?
Maybe:
index < ( blocks-length - 1 ) && (
<VisualEditorSiblingInserterI have some similar thoughts here as in #3246 (review) between this approach and allowing the inserter component itself to consider whether it should render itself. Any thoughts? I don't feel strongly either way.
There was a problem hiding this comment.
The other approach seems fine to me.
|
Related: #3433 (comment) |
|
The sibling inserter has been removed in #4539 I'm closing this PR right now, we can reopen if we bring it back. |
Fixes #3433
Description
Stopped rendering a sibling inserter after the last block
How Has This Been Tested?
Manually.
Types of changes
Condition on rendering a SiblingInserter (not in last position in array of blocks).