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

Make appender fixed position to avoid jumps in the UI #36605

Merged
merged 4 commits into from Nov 19, 2021

Conversation

jasmussen
Copy link
Contributor

Description

Alternative to #36037, which makes the appender fixed position in the top right corner of the nesting container, and to #36602 which simply hides it entirely but only in the site editor.

This variant is based on 36037, but keeps the plus black, and positions it in the bottom right corner. The idea with this one is to make the changes feel smaller — don't redesign the inserter, still keep it towards the end of the nesting container, but just take it out of the flow so it avoids layout shifts.

Post editor demo:

post editor

Site editor demo:

site editor

How has this been tested?

Test in the post editor with this demo content, ensure no regressions:

<!-- wp:paragraph -->
<p>Empty group, should show the big white full width plus:</p>
<!-- /wp:paragraph -->

<!-- wp:group -->
<div class="wp-block-group"></div>
<!-- /wp:group -->

<!-- wp:spacer {"height":50} -->
<div style="height:50px" aria-hidden="true" class="wp-block-spacer"></div>
<!-- /wp:spacer -->

<!-- wp:paragraph -->
<p>Group with content:</p>
<!-- /wp:paragraph -->

<!-- wp:group {"style":{"color":{"background":"#eaeced"}}} -->
<div class="wp-block-group has-background" style="background-color:#eaeced"><!-- wp:paragraph -->
<p>Paragraph 1</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Paragraph 2</p>
<!-- /wp:paragraph --></div>
<!-- /wp:group -->

<!-- wp:spacer {"height":50} -->
<div style="height:50px" aria-hidden="true" class="wp-block-spacer"></div>
<!-- /wp:spacer -->

<!-- wp:paragraph -->
<p>Group with empty paragraph inside, should show plus when selected:</p>
<!-- /wp:paragraph -->

<!-- wp:group {"style":{"color":{"background":"#eaeced"}}} -->
<div class="wp-block-group has-background" style="background-color:#eaeced"><!-- wp:paragraph -->
<p></p>
<!-- /wp:paragraph --></div>
<!-- /wp:group -->

<!-- wp:spacer {"height":50} -->
<div style="height:50px" aria-hidden="true" class="wp-block-spacer"></div>
<!-- /wp:spacer -->

<!-- wp:paragraph -->
<p>Group with single image inside, should show abs positioned plus when selected:</p>
<!-- /wp:paragraph -->

<!-- wp:group {"style":{"color":{"background":"#eaeced"}}} -->
<div class="wp-block-group has-background" style="background-color:#eaeced"><!-- wp:image -->
<figure class="wp-block-image"><img alt=""/></figure>
<!-- /wp:image --></div>
<!-- /wp:group -->

<!-- wp:spacer {"height":50} -->
<div style="height:50px" aria-hidden="true" class="wp-block-spacer"></div>
<!-- /wp:spacer -->

<!-- wp:paragraph -->
<p>A few buttons:</p>
<!-- /wp:paragraph -->

<!-- wp:buttons -->
<div class="wp-block-buttons"><!-- wp:button /-->

<!-- wp:button /--></div>
<!-- /wp:buttons -->

<!-- wp:spacer {"height":50} -->
<div style="height:50px" aria-hidden="true" class="wp-block-spacer"></div>
<!-- /wp:spacer -->

<!-- wp:paragraph -->
<p>Many buttons:</p>
<!-- /wp:paragraph -->

<!-- wp:buttons -->
<div class="wp-block-buttons"><!-- wp:button /-->

<!-- wp:button /-->

<!-- wp:button /-->

<!-- wp:button /-->

<!-- wp:button /-->

<!-- wp:button /-->

<!-- wp:button /--></div>
<!-- /wp:buttons -->

<!-- wp:spacer {"height":50} -->
<div style="height:50px" aria-hidden="true" class="wp-block-spacer"></div>
<!-- /wp:spacer -->

<!-- wp:paragraph -->
<p>Empty cover with empty paragraph inside, paragraph should have black plus when selected:</p>
<!-- /wp:paragraph -->

<!-- wp:cover {"overlayColor":"secondary","minHeight":262,"minHeightUnit":"px","isDark":false} -->
<div class="wp-block-cover is-light" style="min-height:262px"><span aria-hidden="true" class="has-secondary-background-color has-background-dim-100 wp-block-cover__gradient-background has-background-dim"></span><div class="wp-block-cover__inner-container"></div></div>
<!-- /wp:cover -->

<!-- wp:spacer {"height":50} -->
<div style="height:50px" aria-hidden="true" class="wp-block-spacer"></div>
<!-- /wp:spacer -->

<!-- wp:paragraph -->
<p>Another cover:</p>
<!-- /wp:paragraph -->

<!-- wp:cover {"overlayColor":"primary"} -->
<div class="wp-block-cover"><span aria-hidden="true" class="has-primary-background-color has-background-dim-100 wp-block-cover__gradient-background has-background-dim"></span><div class="wp-block-cover__inner-container"><!-- wp:paragraph -->
<p></p>
<!-- /wp:paragraph --></div></div>
<!-- /wp:cover -->

<!-- wp:spacer {"height":50} -->
<div style="height:50px" aria-hidden="true" class="wp-block-spacer"></div>
<!-- /wp:spacer -->

<!-- wp:paragraph -->
<p>Group with Cover inside, should have the plus abs positioned:</p>
<!-- /wp:paragraph -->

<!-- wp:group {"backgroundColor":"secondary"} -->
<div class="wp-block-group has-secondary-background-color has-background"><!-- wp:cover {"isDark":false} -->
<div class="wp-block-cover is-light"><span aria-hidden="true" class="has-background-dim-100 wp-block-cover__gradient-background has-background-dim"></span><div class="wp-block-cover__inner-container"></div></div>
<!-- /wp:cover --></div>
<!-- /wp:group -->

Test in the site editor as well, with selecting nesting containers.

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • I've tested my changes with keyboard and screen readers.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.
  • I've updated all React Native files affected by any refactorings/renamings in this PR (please manually search all *.native.js files for terms that need renaming or removal).

@jasmussen jasmussen added the [Feature] Inserter The main way to insert blocks using the + button in the editing interface label Nov 18, 2021
@jasmussen jasmussen self-assigned this Nov 18, 2021
@github-actions
Copy link

github-actions bot commented Nov 18, 2021

Size Change: -441 B (0%)

Total Size: 1.1 MB

Filename Size Change
build/block-editor/index.min.js 139 kB +55 B (0%)
build/block-editor/style-rtl.css 14.4 kB -7 B (0%)
build/block-editor/style.css 14.4 kB -10 B (0%)
build/block-library/blocks/social-links/editor-rtl.css 670 B -154 B (-19%) 👏
build/block-library/blocks/social-links/editor.css 669 B -154 B (-19%) 👏
build/block-library/editor-rtl.css 9.85 kB -119 B (-1%)
build/block-library/editor.css 9.86 kB -119 B (-1%)
build/edit-site/index.min.js 30.9 kB +67 B (0%)
ℹ️ View Unchanged
Filename Size
build/a11y/index.min.js 960 B
build/admin-manifest/index.min.js 1.1 kB
build/annotations/index.min.js 2.75 kB
build/api-fetch/index.min.js 2.21 kB
build/autop/index.min.js 2.12 kB
build/blob/index.min.js 459 B
build/block-directory/index.min.js 6.28 kB
build/block-directory/style-rtl.css 1.01 kB
build/block-directory/style.css 1.01 kB
build/block-editor/default-editor-styles-rtl.css 378 B
build/block-editor/default-editor-styles.css 378 B
build/block-library/blocks/archives/editor-rtl.css 61 B
build/block-library/blocks/archives/editor.css 60 B
build/block-library/blocks/archives/style-rtl.css 65 B
build/block-library/blocks/archives/style.css 65 B
build/block-library/blocks/audio/editor-rtl.css 58 B
build/block-library/blocks/audio/editor.css 58 B
build/block-library/blocks/audio/style-rtl.css 111 B
build/block-library/blocks/audio/style.css 111 B
build/block-library/blocks/audio/theme-rtl.css 125 B
build/block-library/blocks/audio/theme.css 125 B
build/block-library/blocks/block/editor-rtl.css 161 B
build/block-library/blocks/block/editor.css 161 B
build/block-library/blocks/button/editor-rtl.css 470 B
build/block-library/blocks/button/editor.css 470 B
build/block-library/blocks/button/style-rtl.css 560 B
build/block-library/blocks/button/style.css 560 B
build/block-library/blocks/buttons/editor-rtl.css 291 B
build/block-library/blocks/buttons/editor.css 291 B
build/block-library/blocks/buttons/style-rtl.css 275 B
build/block-library/blocks/buttons/style.css 275 B
build/block-library/blocks/calendar/style-rtl.css 207 B
build/block-library/blocks/calendar/style.css 207 B
build/block-library/blocks/categories/editor-rtl.css 84 B
build/block-library/blocks/categories/editor.css 83 B
build/block-library/blocks/categories/style-rtl.css 79 B
build/block-library/blocks/categories/style.css 79 B
build/block-library/blocks/code/style-rtl.css 90 B
build/block-library/blocks/code/style.css 90 B
build/block-library/blocks/code/theme-rtl.css 134 B
build/block-library/blocks/code/theme.css 134 B
build/block-library/blocks/columns/editor-rtl.css 206 B
build/block-library/blocks/columns/editor.css 205 B
build/block-library/blocks/columns/style-rtl.css 503 B
build/block-library/blocks/columns/style.css 502 B
build/block-library/blocks/cover/editor-rtl.css 546 B
build/block-library/blocks/cover/editor.css 547 B
build/block-library/blocks/cover/style-rtl.css 1.19 kB
build/block-library/blocks/cover/style.css 1.19 kB
build/block-library/blocks/embed/editor-rtl.css 488 B
build/block-library/blocks/embed/editor.css 488 B
build/block-library/blocks/embed/style-rtl.css 417 B
build/block-library/blocks/embed/style.css 417 B
build/block-library/blocks/embed/theme-rtl.css 124 B
build/block-library/blocks/embed/theme.css 124 B
build/block-library/blocks/file/editor-rtl.css 300 B
build/block-library/blocks/file/editor.css 300 B
build/block-library/blocks/file/style-rtl.css 255 B
build/block-library/blocks/file/style.css 255 B
build/block-library/blocks/file/view.min.js 322 B
build/block-library/blocks/freeform/editor-rtl.css 2.44 kB
build/block-library/blocks/freeform/editor.css 2.44 kB
build/block-library/blocks/gallery/editor-rtl.css 977 B
build/block-library/blocks/gallery/editor.css 982 B
build/block-library/blocks/gallery/style-rtl.css 1.62 kB
build/block-library/blocks/gallery/style.css 1.62 kB
build/block-library/blocks/gallery/theme-rtl.css 122 B
build/block-library/blocks/gallery/theme.css 122 B
build/block-library/blocks/group/editor-rtl.css 159 B
build/block-library/blocks/group/editor.css 159 B
build/block-library/blocks/group/style-rtl.css 57 B
build/block-library/blocks/group/style.css 57 B
build/block-library/blocks/group/theme-rtl.css 78 B
build/block-library/blocks/group/theme.css 78 B
build/block-library/blocks/heading/style-rtl.css 114 B
build/block-library/blocks/heading/style.css 114 B
build/block-library/blocks/html/editor-rtl.css 332 B
build/block-library/blocks/html/editor.css 333 B
build/block-library/blocks/image/editor-rtl.css 731 B
build/block-library/blocks/image/editor.css 730 B
build/block-library/blocks/image/style-rtl.css 507 B
build/block-library/blocks/image/style.css 511 B
build/block-library/blocks/image/theme-rtl.css 124 B
build/block-library/blocks/image/theme.css 124 B
build/block-library/blocks/latest-comments/style-rtl.css 284 B
build/block-library/blocks/latest-comments/style.css 284 B
build/block-library/blocks/latest-posts/editor-rtl.css 137 B
build/block-library/blocks/latest-posts/editor.css 137 B
build/block-library/blocks/latest-posts/style-rtl.css 528 B
build/block-library/blocks/latest-posts/style.css 527 B
build/block-library/blocks/list/style-rtl.css 94 B
build/block-library/blocks/list/style.css 94 B
build/block-library/blocks/media-text/editor-rtl.css 266 B
build/block-library/blocks/media-text/editor.css 263 B
build/block-library/blocks/media-text/style-rtl.css 493 B
build/block-library/blocks/media-text/style.css 490 B
build/block-library/blocks/more/editor-rtl.css 431 B
build/block-library/blocks/more/editor.css 431 B
build/block-library/blocks/navigation-link/editor-rtl.css 649 B
build/block-library/blocks/navigation-link/editor.css 650 B
build/block-library/blocks/navigation-link/style-rtl.css 94 B
build/block-library/blocks/navigation-link/style.css 94 B
build/block-library/blocks/navigation-submenu/editor-rtl.css 299 B
build/block-library/blocks/navigation-submenu/editor.css 299 B
build/block-library/blocks/navigation-submenu/style-rtl.css 213 B
build/block-library/blocks/navigation-submenu/style.css 213 B
build/block-library/blocks/navigation-submenu/view.min.js 343 B
build/block-library/blocks/navigation/editor-rtl.css 1.89 kB
build/block-library/blocks/navigation/editor.css 1.89 kB
build/block-library/blocks/navigation/style-rtl.css 1.58 kB
build/block-library/blocks/navigation/style.css 1.57 kB
build/block-library/blocks/navigation/view.min.js 2.74 kB
build/block-library/blocks/nextpage/editor-rtl.css 395 B
build/block-library/blocks/nextpage/editor.css 395 B
build/block-library/blocks/page-list/editor-rtl.css 377 B
build/block-library/blocks/page-list/editor.css 377 B
build/block-library/blocks/page-list/style-rtl.css 172 B
build/block-library/blocks/page-list/style.css 172 B
build/block-library/blocks/paragraph/editor-rtl.css 157 B
build/block-library/blocks/paragraph/editor.css 157 B
build/block-library/blocks/paragraph/style-rtl.css 273 B
build/block-library/blocks/paragraph/style.css 273 B
build/block-library/blocks/post-author/style-rtl.css 175 B
build/block-library/blocks/post-author/style.css 176 B
build/block-library/blocks/post-comments-form/style-rtl.css 444 B
build/block-library/blocks/post-comments-form/style.css 444 B
build/block-library/blocks/post-comments/style-rtl.css 492 B
build/block-library/blocks/post-comments/style.css 493 B
build/block-library/blocks/post-excerpt/editor-rtl.css 73 B
build/block-library/blocks/post-excerpt/editor.css 73 B
build/block-library/blocks/post-excerpt/style-rtl.css 69 B
build/block-library/blocks/post-excerpt/style.css 69 B
build/block-library/blocks/post-featured-image/editor-rtl.css 771 B
build/block-library/blocks/post-featured-image/editor.css 771 B
build/block-library/blocks/post-featured-image/style-rtl.css 153 B
build/block-library/blocks/post-featured-image/style.css 153 B
build/block-library/blocks/post-template/editor-rtl.css 99 B
build/block-library/blocks/post-template/editor.css 98 B
build/block-library/blocks/post-template/style-rtl.css 391 B
build/block-library/blocks/post-template/style.css 392 B
build/block-library/blocks/post-terms/style-rtl.css 73 B
build/block-library/blocks/post-terms/style.css 73 B
build/block-library/blocks/post-title/style-rtl.css 80 B
build/block-library/blocks/post-title/style.css 80 B
build/block-library/blocks/preformatted/style-rtl.css 103 B
build/block-library/blocks/preformatted/style.css 103 B
build/block-library/blocks/pullquote/editor-rtl.css 198 B
build/block-library/blocks/pullquote/editor.css 198 B
build/block-library/blocks/pullquote/style-rtl.css 378 B
build/block-library/blocks/pullquote/style.css 378 B
build/block-library/blocks/pullquote/theme-rtl.css 167 B
build/block-library/blocks/pullquote/theme.css 167 B
build/block-library/blocks/query-pagination-numbers/editor-rtl.css 122 B
build/block-library/blocks/query-pagination-numbers/editor.css 121 B
build/block-library/blocks/query-pagination/editor-rtl.css 262 B
build/block-library/blocks/query-pagination/editor.css 255 B
build/block-library/blocks/query-pagination/style-rtl.css 234 B
build/block-library/blocks/query-pagination/style.css 231 B
build/block-library/blocks/query/editor-rtl.css 131 B
build/block-library/blocks/query/editor.css 132 B
build/block-library/blocks/quote/style-rtl.css 187 B
build/block-library/blocks/quote/style.css 187 B
build/block-library/blocks/quote/theme-rtl.css 223 B
build/block-library/blocks/quote/theme.css 226 B
build/block-library/blocks/rss/editor-rtl.css 202 B
build/block-library/blocks/rss/editor.css 204 B
build/block-library/blocks/rss/style-rtl.css 289 B
build/block-library/blocks/rss/style.css 288 B
build/block-library/blocks/search/editor-rtl.css 165 B
build/block-library/blocks/search/editor.css 165 B
build/block-library/blocks/search/style-rtl.css 397 B
build/block-library/blocks/search/style.css 398 B
build/block-library/blocks/search/theme-rtl.css 64 B
build/block-library/blocks/search/theme.css 64 B
build/block-library/blocks/separator/editor-rtl.css 99 B
build/block-library/blocks/separator/editor.css 99 B
build/block-library/blocks/separator/style-rtl.css 245 B
build/block-library/blocks/separator/style.css 245 B
build/block-library/blocks/separator/theme-rtl.css 172 B
build/block-library/blocks/separator/theme.css 172 B
build/block-library/blocks/shortcode/editor-rtl.css 474 B
build/block-library/blocks/shortcode/editor.css 474 B
build/block-library/blocks/site-logo/editor-rtl.css 770 B
build/block-library/blocks/site-logo/editor.css 770 B
build/block-library/blocks/site-logo/style-rtl.css 165 B
build/block-library/blocks/site-logo/style.css 165 B
build/block-library/blocks/site-tagline/editor-rtl.css 86 B
build/block-library/blocks/site-tagline/editor.css 86 B
build/block-library/blocks/site-title/editor-rtl.css 84 B
build/block-library/blocks/site-title/editor.css 84 B
build/block-library/blocks/social-link/editor-rtl.css 177 B
build/block-library/blocks/social-link/editor.css 177 B
build/block-library/blocks/social-links/style-rtl.css 1.32 kB
build/block-library/blocks/social-links/style.css 1.32 kB
build/block-library/blocks/spacer/editor-rtl.css 307 B
build/block-library/blocks/spacer/editor.css 307 B
build/block-library/blocks/spacer/style-rtl.css 48 B
build/block-library/blocks/spacer/style.css 48 B
build/block-library/blocks/table/editor-rtl.css 471 B
build/block-library/blocks/table/editor.css 472 B
build/block-library/blocks/table/style-rtl.css 481 B
build/block-library/blocks/table/style.css 481 B
build/block-library/blocks/table/theme-rtl.css 188 B
build/block-library/blocks/table/theme.css 188 B
build/block-library/blocks/tag-cloud/style-rtl.css 146 B
build/block-library/blocks/tag-cloud/style.css 146 B
build/block-library/blocks/template-part/editor-rtl.css 560 B
build/block-library/blocks/template-part/editor.css 559 B
build/block-library/blocks/template-part/theme-rtl.css 101 B
build/block-library/blocks/template-part/theme.css 101 B
build/block-library/blocks/text-columns/editor-rtl.css 95 B
build/block-library/blocks/text-columns/editor.css 95 B
build/block-library/blocks/text-columns/style-rtl.css 166 B
build/block-library/blocks/text-columns/style.css 166 B
build/block-library/blocks/verse/style-rtl.css 87 B
build/block-library/blocks/verse/style.css 87 B
build/block-library/blocks/video/editor-rtl.css 569 B
build/block-library/blocks/video/editor.css 570 B
build/block-library/blocks/video/style-rtl.css 173 B
build/block-library/blocks/video/style.css 173 B
build/block-library/blocks/video/theme-rtl.css 124 B
build/block-library/blocks/video/theme.css 124 B
build/block-library/common-rtl.css 815 B
build/block-library/common.css 812 B
build/block-library/index.min.js 162 kB
build/block-library/reset-rtl.css 474 B
build/block-library/reset.css 474 B
build/block-library/style-rtl.css 10.4 kB
build/block-library/style.css 10.5 kB
build/block-library/theme-rtl.css 672 B
build/block-library/theme.css 677 B
build/block-serialization-default-parser/index.min.js 1.09 kB
build/block-serialization-spec-parser/index.min.js 2.79 kB
build/blocks/index.min.js 46.3 kB
build/components/index.min.js 214 kB
build/components/style-rtl.css 15.3 kB
build/components/style.css 15.3 kB
build/compose/index.min.js 10.9 kB
build/core-data/index.min.js 13.2 kB
build/customize-widgets/index.min.js 11.4 kB
build/customize-widgets/style-rtl.css 1.5 kB
build/customize-widgets/style.css 1.49 kB
build/data-controls/index.min.js 631 B
build/data/index.min.js 7.42 kB
build/date/index.min.js 31.5 kB
build/deprecated/index.min.js 485 B
build/dom-ready/index.min.js 304 B
build/dom/index.min.js 4.5 kB
build/edit-navigation/index.min.js 16 kB
build/edit-navigation/style-rtl.css 3.76 kB
build/edit-navigation/style.css 3.76 kB
build/edit-post/classic-rtl.css 492 B
build/edit-post/classic.css 494 B
build/edit-post/index.min.js 29.6 kB
build/edit-post/style-rtl.css 7.1 kB
build/edit-post/style.css 7.09 kB
build/edit-site/style-rtl.css 6.29 kB
build/edit-site/style.css 6.28 kB
build/edit-widgets/index.min.js 16.5 kB
build/edit-widgets/style-rtl.css 4.18 kB
build/edit-widgets/style.css 4.18 kB
build/editor/index.min.js 37.8 kB
build/editor/style-rtl.css 3.78 kB
build/editor/style.css 3.77 kB
build/element/index.min.js 3.29 kB
build/escape-html/index.min.js 517 B
build/format-library/index.min.js 6.57 kB
build/format-library/style-rtl.css 571 B
build/format-library/style.css 571 B
build/hooks/index.min.js 1.63 kB
build/html-entities/index.min.js 424 B
build/i18n/index.min.js 3.71 kB
build/is-shallow-equal/index.min.js 501 B
build/keyboard-shortcuts/index.min.js 1.8 kB
build/keycodes/index.min.js 1.39 kB
build/list-reusable-blocks/index.min.js 1.86 kB
build/list-reusable-blocks/style-rtl.css 838 B
build/list-reusable-blocks/style.css 838 B
build/media-utils/index.min.js 2.92 kB
build/notices/index.min.js 925 B
build/nux/index.min.js 2.08 kB
build/nux/style-rtl.css 747 B
build/nux/style.css 743 B
build/plugins/index.min.js 1.84 kB
build/primitives/index.min.js 924 B
build/priority-queue/index.min.js 582 B
build/react-i18n/index.min.js 671 B
build/redux-routine/index.min.js 2.65 kB
build/reusable-blocks/index.min.js 2.22 kB
build/reusable-blocks/style-rtl.css 256 B
build/reusable-blocks/style.css 256 B
build/rich-text/index.min.js 11 kB
build/server-side-render/index.min.js 1.57 kB
build/shortcode/index.min.js 1.49 kB
build/token-list/index.min.js 639 B
build/url/index.min.js 1.9 kB
build/viewport/index.min.js 1.05 kB
build/warning/index.min.js 248 B
build/widgets/index.min.js 7.15 kB
build/widgets/style-rtl.css 1.16 kB
build/widgets/style.css 1.16 kB
build/wordcount/index.min.js 1.04 kB

compressed-size-action

@ZebulanStanphill
Copy link
Member

This is definitely my favorite approach of the three. Having the appender appear inside the container makes it a lot clearer that it inserts into the block rather than after.

The lack of appender when a single Button block is selected does feel off, but I'm not sure what the solution is there.

I'm noticing a bug with the current implementation, though. The appender is not appearing for Group blocks.
image

It is working fine with the Column and Buttons blocks:
image

I also noticed this issue with the Buttons in-between inserter not acting as expected, but I don't know if that's related to this PR. It does compound with the lack of appender to make inserting Button blocks feel noticeably less ergonomic.
image

If we later go the route of having appenders in the toolbar, perhaps one could be shown in the toolbar like so to provide a clear way of adding block to the parent of the current block:
image

@jasmussen
Copy link
Contributor Author

Thanks for the review!

I'm noticing a bug with the current implementation, though. The appender is not appearing for Group blocks.

Can you just verify if this isn't the same on trunk, though? Because I seem to recall a behavior where if you only have paragraphs inside a container, the appender isn't shown after either of them, whereas if you have, for example, an Image block inside, then it's shown. Definitely behavior to revisit in its own right, but just for the sake of this PR I think it's best to keep that separate.

I also noticed this issue with the Buttons in-between inserter not acting as expected, but I don't know if that's related to this PR. It does compound with the lack of appender to make inserting Button blocks feel noticeably less ergonomic.

I've been having a fair amount of problems with the that inbetween inserter lately, and I'm hoping we can get some help to look at it, including #35536. I don't know how this PR would affect it, though, as it's separate markup outside the canvas (popover) and shouldn't be subject to the CSS I've got here.

I would agree the ergonomics aren't ideal here, and even just making the inserter work before and after the last blocks (illustrated here) could help bit.

@ZebulanStanphill
Copy link
Member

Thanks for the review!

I'm noticing a bug with the current implementation, though. The appender is not appearing for Group blocks.

Can you just verify if this isn't the same on trunk, though? Because I seem to recall a behavior where if you only have paragraphs inside a container, the appender isn't shown after either of them, whereas if you have, for example, an Image block inside, then it's shown. Definitely behavior to revisit in its own right, but just for the sake of this PR I think it's best to keep that separate.

I specifically put a Heading block as the last block of the Group to see if that fixed the problem, but it didn't. I also just tried an Image block but it still didn't work.

Just tested trunk as well. The appender appears as expected when the Group is expected, so it's not a trunk issue.

I would agree the ergonomics aren't ideal here, and even just making the inserter work before and after the last blocks (illustrated here) could help bit.

Agreed.

@shaunandrews
Copy link
Contributor

shaunandrews commented Nov 18, 2021

Really love the way this one is shaping up; Nice work.

Visually, my only niggle is the placement of the [ + ] button and how it touches the focus outline of the block.

image

To me it feels unintentional, but I know the point is to visually connect the add button to the focused block. I think it would feel better if there was a little space (I used 3px) around the button, and let the existing context (things like the focus outline and block toolbar) tie the button to the container.

image

I think a good companion PR to this one could explore more explanation for where your block is going to be added. Right now, this PR can confuse adding blocks within deeply nested blocks, like a Buttons block within a Group block. Here's an example that uses a 3px blue "insertion guide" to help indicate where the new block will be added:

Container.Inserter.Guide.mp4

@shaunandrews
Copy link
Contributor

I specifically put a Heading block as the last block of the Group to see if that fixed the problem, but it didn't. I also just tried an Image block but it still didn't work.

With just a Paragraph and Heading block, I don't see a [ + ] for the Group — which I believe is intentional. When I add an Image block, then I do see the [ + ] button, which contradicts with your testing. I'm not sure what's going on, but I've tried it with more types of blocks and can reliably get the [ + ] when I expect it.

@ZebulanStanphill
Copy link
Member

@shaunandrews I'm using https://gutenberg.run for testing. Maybe there's an issue caused by its WP environment being a bit out-of-date? It is running WP 5.7 with Twenty Twenty-One 1.2. Changing the theme to Twenty Twenty or Twenty Nineteen does not fix the issue. I just tested the branch again and I still can't see the appender in a Group:

image

There are no console errors.

Also, in trunk, the only block that has special appender behavior is the Paragraph. The appender still appears after Heading blocks. So if you're not seeing the appender in a Group when the last child is a Heading, that's technically a regression.

In the pictures you posted above, the heading is the first block, but whether the appender is shown only depends on what the last child block is.

@jasmussen
Copy link
Contributor Author

I do see the appender after the heading:
Screenshot 2021-11-19 at 09 03 03

I'm investigating a few thigns and will try and address the feedback noted. Whether we're able to land this one or not, I'd like to shepard it along as best I can.

@jasmussen
Copy link
Contributor Author

Visually, my only niggle is the placement of the [ + ] button and how it touches the focus outline of the block.

Screenshot 2021-11-19 at 09 04 54

I do kind of like that it's as much on the edge as it can be, meaning it covers as little as possible of the content inside. Also that it lines up below. But this is not a strong opinion, and I'd be happy to add a few pixels of spacing if need be. Let me address the other things and I'll come back to this one.

@jasmussen
Copy link
Contributor Author

jasmussen commented Nov 19, 2021

Alright, I've rebased and fixed an issue with the plus not appearing in some odd cases. Specifically it wasn't working inside navigation, which I've now fixed:
navigation and group

Shown here also the behavior that the appender for the group will only show when the group is selected, not for when content inside is selected. This is based on feedback here, (and of the 3 commits to this branch, is defined by commits 2 and 3), and is mostly important for the site editor, where without it, you'd have this:

With the change to only show the plus for the selected container, it feels much more contextual:

It essentially leans into the idea that we have too many plusses and we need to remove some of them. That also challenges a bit of muscle memory we've built up.

To me it feels unintentional, but I know the point is to visually connect the add button to the focused block. I think it would feel better if there was a little space (I used 3px) around the button, and let the existing context (things like the focus outline and block toolbar) tie the button to the container.

I tried this, and despite my previous thought agree that it looks good in many cases. However then I realized that for really small containers, like Navigation, you'd end up with this:

Screenshot 2021-11-19 at 09 37 19

That's more of a critique of this button itself than anything, but it's the reason why I'm leaning towards leaving out that change for now.

Here's the test content:

test content

Here's the site editor:
site editor

I wanted to bring attention to one change to what I've been referring to as the "trailing appender". This is when you have a not-text-block (such as an image) as the last block in a block list. This is the appender I think we should look at removing, separately. In trunk, it sits on the left:

trunk

In this branch it now sits on the right:

this branch

Given the plus that sits inside an empty paragraph was always on the right, I actually think this is a good change. But it's nevertheless a change.

Copy link
Member

@ellatrix ellatrix left a comment

Choose a reason for hiding this comment

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

Looks good to me. I actually like that there's no space between the block outline and the plus icon.

@jasmussen
Copy link
Contributor Author

Looks like some of the test failures here are legitimate, probably due to the changes to not show the appender on ancestors.

@jasmussen
Copy link
Contributor Author

I won't press the button until you've all had a say! Take all the time you need, thank you for looking.

@youknowriad
Copy link
Contributor

This is very cool :)

For me, the only thing that bothered me is the fact that container blocks (group, row, column, cover) don't show the appender when the last block is a paragraph, I think that behavior doesn't make sense anymore with the appender being absolute positioned.

@youknowriad
Copy link
Contributor

I also like all the style removals 👏

@jasmussen
Copy link
Contributor Author

For me, the only thing that bothered me is the fact that container blocks (group, row, column, cover) don't show the appender when the last block is a paragraph, I think that behavior doesn't make sense anymore with the appender being absolute positioned.

@ellatrix I think mentioned this particular type of appender as well. Just to be sure, do you feel like the plus should be shown regardless of content? Or shouldn't be shown?

@jasmussen
Copy link
Contributor Author

(And either way, feel free to push to this branch if you like, I think it migh be beyond my skill to change that)

@youknowriad
Copy link
Contributor

For me, it should always be shown (maybe just an exception for the root).

Let's merge this and I can attempt this change separately.

@youknowriad youknowriad added the Backport to WP Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta label Nov 19, 2021
@jasmussen
Copy link
Contributor Author

Sounds good. I wanted to note one side effect with the navigation submenu that I'd like to follow up on separately. When clicking a submenu, the black plus is there to add a submenu item, that works well:
Screenshot 2021-11-19 at 15 25 20

The change to only show this black plus when the container block is selected, though, has the side effect that this plus disappears as soon as you add an item inside:
Screenshot 2021-11-19 at 15 25 24

I actually think this PR is healthy to merge because it shows all these side effects that are important to consider as we improve the situation here inside the component itself, with some more obvious and predictable visibility behaviors perhaps as props. In the mean time, I can whip up a quick fix for the navigation block editor.scss file to surface that black plus, even when a submenu item is selected.

If you agree, feel free to press the green button and I'll follow up.

@youknowriad youknowriad merged commit d69d172 into trunk Nov 19, 2021
@youknowriad youknowriad deleted the try/alternate-fixed-appender branch November 19, 2021 14:33
@youknowriad youknowriad changed the title Try: Make appender fixed position, alternate version Make appender fixed position to avoid jumps in the UI Nov 19, 2021
@github-actions github-actions bot added this to the Gutenberg 12.1 milestone Nov 19, 2021
@ZebulanStanphill
Copy link
Member

Just posting to confirm that the appender is now appearing as expected in Group blocks for me, and also that I, too, prefer having the appender touching the block border as it does now.

@noisysocks noisysocks removed the Backport to WP Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta label Nov 22, 2021
noisysocks pushed a commit that referenced this pull request Nov 22, 2021
Co-authored-by: Ella van Durpe <ella@vandurpe.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Inserter The main way to insert blocks using the + button in the editing interface
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants