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

Sticky Position: Try re-enabling non-root sticky position #49321

Merged
merged 10 commits into from
Jun 16, 2023

Conversation

andrewserong
Copy link
Contributor

@andrewserong andrewserong commented Mar 24, 2023

What?

Part of #47043, will ideally resolve #47892

This PR explores re-enabling sticky position at non-root positions within the document, and adds paragraph / help text beneath the position drop-down selection when Sticky is set, so that we describe in text that the block will be sticky to its parent.

Early versions of this PR also explored adding in a position visualizer of some kind, however it was uncertain as to how to make this truly beneficial or useful. For now, this PR has been pared back to just re-enabling non-root positions, and adding in the help text.

Why?

For the initial version of sticky positioning, support for sticky being set at non-root positions was removed because of the potential confusion for users. The goal with this PR is to explore what sorts of things we can do in the UI to help ease some of that confusion, and to determine whether or not it's enough to re-enable non-root position values.

How?

  • Enable sticky position at non-root positions.
  • Add help text beneath the drop-down select when sticky is set.

To-do items

Testing Instructions

Copy / paste some test markup below (a sticky group in a column):

Block markup for a sticky group within a column in a columns block
<!-- wp:columns {"align":"wide","style":{"spacing":{"padding":{"top":"var:preset|spacing|30","right":"var:preset|spacing|30","bottom":"var:preset|spacing|30","left":"var:preset|spacing|30"}}},"backgroundColor":"tertiary"} -->
<div class="wp-block-columns alignwide has-tertiary-background-color has-background" style="padding-top:var(--wp--preset--spacing--30);padding-right:var(--wp--preset--spacing--30);padding-bottom:var(--wp--preset--spacing--30);padding-left:var(--wp--preset--spacing--30)"><!-- wp:column {"width":"40%"} -->
<div class="wp-block-column" style="flex-basis:40%"><!-- wp:group {"style":{"spacing":{"padding":{"top":"var:preset|spacing|30","right":"var:preset|spacing|30","bottom":"var:preset|spacing|30","left":"var:preset|spacing|30"}},"position":{"type":"sticky","top":"0px"}},"backgroundColor":"cyan-bluish-gray","layout":{"type":"constrained"}} -->
<div class="wp-block-group has-cyan-bluish-gray-background-color has-background" style="padding-top:var(--wp--preset--spacing--30);padding-right:var(--wp--preset--spacing--30);padding-bottom:var(--wp--preset--spacing--30);padding-left:var(--wp--preset--spacing--30)"><!-- wp:heading {"level":3} -->
<h3 class="wp-block-heading">A sticky card</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Here is a description to be contained within this sticky element within the sidebar. It could be a little information about the author, or it could include a button of some kind.</p>
<!-- /wp:paragraph -->

<!-- wp:buttons -->
<div class="wp-block-buttons"><!-- wp:button {"backgroundColor":"contrast","textColor":"base"} -->
<div class="wp-block-button"><a class="wp-block-button__link has-base-color has-contrast-background-color has-text-color has-background wp-element-button">Contact</a></div>
<!-- /wp:button --></div>
<!-- /wp:buttons --></div>
<!-- /wp:group --></div>
<!-- /wp:column -->

<!-- wp:column {"width":"60%"} -->
<div class="wp-block-column" style="flex-basis:60%"><!-- wp:group {"layout":{"type":"flex","flexWrap":"wrap","justifyContent":"right"}} -->
<div class="wp-block-group"><!-- wp:group {"style":{"layout":{"selfStretch":"fixed","flexSize":"300px"},"dimensions":{"minHeight":"250px"}},"backgroundColor":"pale-cyan-blue","layout":{"type":"constrained"}} -->
<div class="wp-block-group has-pale-cyan-blue-background-color has-background" style="min-height:250px"></div>
<!-- /wp:group -->

<!-- wp:group {"style":{"layout":{"selfStretch":"fixed","flexSize":"300px"},"dimensions":{"minHeight":"250px"}},"backgroundColor":"light-green-cyan","layout":{"type":"constrained"}} -->
<div class="wp-block-group has-light-green-cyan-background-color has-background" style="min-height:250px"></div>
<!-- /wp:group -->

<!-- wp:group {"style":{"layout":{"selfStretch":"fixed","flexSize":"300px"},"dimensions":{"minHeight":"250px"}},"backgroundColor":"light-green-cyan","layout":{"type":"constrained"}} -->
<div class="wp-block-group has-light-green-cyan-background-color has-background" style="min-height:250px"></div>
<!-- /wp:group -->

<!-- wp:group {"style":{"layout":{"selfStretch":"fixed","flexSize":"300px"},"dimensions":{"minHeight":"250px"}},"backgroundColor":"pale-cyan-blue","layout":{"type":"constrained"}} -->
<div class="wp-block-group has-pale-cyan-blue-background-color has-background" style="min-height:250px"></div>
<!-- /wp:group -->

<!-- wp:group {"style":{"layout":{"selfStretch":"fixed","flexSize":"300px"},"dimensions":{"minHeight":"250px"}},"backgroundColor":"pale-cyan-blue","layout":{"type":"constrained"}} -->
<div class="wp-block-group has-pale-cyan-blue-background-color has-background" style="min-height:250px"></div>
<!-- /wp:group -->

<!-- wp:group {"style":{"layout":{"selfStretch":"fixed","flexSize":"300px"},"dimensions":{"minHeight":"250px"}},"backgroundColor":"light-green-cyan","layout":{"type":"constrained"}} -->
<div class="wp-block-group has-light-green-cyan-background-color has-background" style="min-height:250px"></div>
<!-- /wp:group -->

<!-- wp:group {"style":{"layout":{"selfStretch":"fixed","flexSize":"300px"},"dimensions":{"minHeight":"250px"}},"backgroundColor":"light-green-cyan","layout":{"type":"constrained"}} -->
<div class="wp-block-group has-light-green-cyan-background-color has-background" style="min-height:250px"></div>
<!-- /wp:group -->

<!-- wp:group {"style":{"layout":{"selfStretch":"fixed","flexSize":"300px"},"dimensions":{"minHeight":"250px"}},"backgroundColor":"pale-cyan-blue","layout":{"type":"constrained"}} -->
<div class="wp-block-group has-pale-cyan-blue-background-color has-background" style="min-height:250px"></div>
<!-- /wp:group --></div>
<!-- /wp:group --></div>
<!-- /wp:column --></div>
<!-- /wp:columns -->

Or, construct your own pattern:

  1. Add a Group block as a child of a Group block that also contains some paragraph text.
  2. Add a background color to the parent Group block so that it's a little clearer what's going on.
  3. Add paragraph text after the parent Group block so that you can see the scroll behaviour take effect.
  4. In the nested Group block, give it its own background color, and add some paragraph text to it.
  5. Set this nested Group block to "sticky" and test the UI.

Screenshots or screencast

image

Site frontend:

2023-04-26.16.20.34.mp4

@andrewserong andrewserong added [Type] Experimental Experimental feature or API. [Feature] Design Tools Tools that impact the appearance of blocks both to expand the number of tools and improve the experi labels Mar 24, 2023
@andrewserong andrewserong self-assigned this Mar 24, 2023
@github-actions
Copy link

github-actions bot commented Mar 24, 2023

Size Change: +45 B (0%)

Total Size: 1.4 MB

Filename Size Change
build/block-editor/index.min.js 195 kB +45 B (0%)
ℹ️ View Unchanged
Filename Size
build/a11y/index.min.js 955 B
build/annotations/index.min.js 2.69 kB
build/api-fetch/index.min.js 2.29 kB
build/autop/index.min.js 2.1 kB
build/blob/index.min.js 451 B
build/block-directory/index.min.js 7.05 kB
build/block-directory/style-rtl.css 1.02 kB
build/block-directory/style.css 1.02 kB
build/block-editor/content-rtl.css 4.22 kB
build/block-editor/content.css 4.22 kB
build/block-editor/default-editor-styles-rtl.css 381 B
build/block-editor/default-editor-styles.css 381 B
build/block-editor/style-rtl.css 14.9 kB
build/block-editor/style.css 14.9 kB
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 90 B
build/block-library/blocks/archives/style.css 90 B
build/block-library/blocks/audio/editor-rtl.css 150 B
build/block-library/blocks/audio/editor.css 150 B
build/block-library/blocks/audio/style-rtl.css 122 B
build/block-library/blocks/audio/style.css 122 B
build/block-library/blocks/audio/theme-rtl.css 126 B
build/block-library/blocks/audio/theme.css 126 B
build/block-library/blocks/avatar/editor-rtl.css 116 B
build/block-library/blocks/avatar/editor.css 116 B
build/block-library/blocks/avatar/style-rtl.css 104 B
build/block-library/blocks/avatar/style.css 104 B
build/block-library/blocks/block/editor-rtl.css 305 B
build/block-library/blocks/block/editor.css 305 B
build/block-library/blocks/button/editor-rtl.css 584 B
build/block-library/blocks/button/editor.css 582 B
build/block-library/blocks/button/style-rtl.css 624 B
build/block-library/blocks/button/style.css 623 B
build/block-library/blocks/buttons/editor-rtl.css 337 B
build/block-library/blocks/buttons/editor.css 337 B
build/block-library/blocks/buttons/style-rtl.css 332 B
build/block-library/blocks/buttons/style.css 332 B
build/block-library/blocks/calendar/style-rtl.css 239 B
build/block-library/blocks/calendar/style.css 239 B
build/block-library/blocks/categories/editor-rtl.css 113 B
build/block-library/blocks/categories/editor.css 112 B
build/block-library/blocks/categories/style-rtl.css 124 B
build/block-library/blocks/categories/style.css 124 B
build/block-library/blocks/code/editor-rtl.css 53 B
build/block-library/blocks/code/editor.css 53 B
build/block-library/blocks/code/style-rtl.css 121 B
build/block-library/blocks/code/style.css 121 B
build/block-library/blocks/code/theme-rtl.css 124 B
build/block-library/blocks/code/theme.css 124 B
build/block-library/blocks/columns/editor-rtl.css 108 B
build/block-library/blocks/columns/editor.css 108 B
build/block-library/blocks/columns/style-rtl.css 409 B
build/block-library/blocks/columns/style.css 409 B
build/block-library/blocks/comment-author-avatar/editor-rtl.css 125 B
build/block-library/blocks/comment-author-avatar/editor.css 125 B
build/block-library/blocks/comment-content/style-rtl.css 92 B
build/block-library/blocks/comment-content/style.css 92 B
build/block-library/blocks/comment-template/style-rtl.css 199 B
build/block-library/blocks/comment-template/style.css 198 B
build/block-library/blocks/comments-pagination-numbers/editor-rtl.css 123 B
build/block-library/blocks/comments-pagination-numbers/editor.css 121 B
build/block-library/blocks/comments-pagination/editor-rtl.css 222 B
build/block-library/blocks/comments-pagination/editor.css 209 B
build/block-library/blocks/comments-pagination/style-rtl.css 235 B
build/block-library/blocks/comments-pagination/style.css 231 B
build/block-library/blocks/comments-title/editor-rtl.css 75 B
build/block-library/blocks/comments-title/editor.css 75 B
build/block-library/blocks/comments/editor-rtl.css 840 B
build/block-library/blocks/comments/editor.css 839 B
build/block-library/blocks/comments/style-rtl.css 637 B
build/block-library/blocks/comments/style.css 636 B
build/block-library/blocks/cover/editor-rtl.css 647 B
build/block-library/blocks/cover/editor.css 650 B
build/block-library/blocks/cover/style-rtl.css 1.61 kB
build/block-library/blocks/cover/style.css 1.6 kB
build/block-library/blocks/details/editor-rtl.css 65 B
build/block-library/blocks/details/editor.css 65 B
build/block-library/blocks/details/style-rtl.css 159 B
build/block-library/blocks/details/style.css 159 B
build/block-library/blocks/embed/editor-rtl.css 293 B
build/block-library/blocks/embed/editor.css 293 B
build/block-library/blocks/embed/style-rtl.css 410 B
build/block-library/blocks/embed/style.css 410 B
build/block-library/blocks/embed/theme-rtl.css 126 B
build/block-library/blocks/embed/theme.css 126 B
build/block-library/blocks/file/editor-rtl.css 316 B
build/block-library/blocks/file/editor.css 316 B
build/block-library/blocks/file/interactivity.min.js 395 B
build/block-library/blocks/file/style-rtl.css 269 B
build/block-library/blocks/file/style.css 270 B
build/block-library/blocks/freeform/editor-rtl.css 2.58 kB
build/block-library/blocks/freeform/editor.css 2.58 kB
build/block-library/blocks/gallery/editor-rtl.css 947 B
build/block-library/blocks/gallery/editor.css 952 B
build/block-library/blocks/gallery/style-rtl.css 1.53 kB
build/block-library/blocks/gallery/style.css 1.53 kB
build/block-library/blocks/gallery/theme-rtl.css 108 B
build/block-library/blocks/gallery/theme.css 108 B
build/block-library/blocks/group/editor-rtl.css 654 B
build/block-library/blocks/group/editor.css 654 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 76 B
build/block-library/blocks/heading/style.css 76 B
build/block-library/blocks/html/editor-rtl.css 336 B
build/block-library/blocks/html/editor.css 337 B
build/block-library/blocks/image/editor-rtl.css 834 B
build/block-library/blocks/image/editor.css 833 B
build/block-library/blocks/image/interactivity.min.js 1.34 kB
build/block-library/blocks/image/style-rtl.css 1.34 kB
build/block-library/blocks/image/style.css 1.34 kB
build/block-library/blocks/image/theme-rtl.css 126 B
build/block-library/blocks/image/theme.css 126 B
build/block-library/blocks/latest-comments/style-rtl.css 357 B
build/block-library/blocks/latest-comments/style.css 357 B
build/block-library/blocks/latest-posts/editor-rtl.css 213 B
build/block-library/blocks/latest-posts/editor.css 212 B
build/block-library/blocks/latest-posts/style-rtl.css 478 B
build/block-library/blocks/latest-posts/style.css 478 B
build/block-library/blocks/list/style-rtl.css 88 B
build/block-library/blocks/list/style.css 88 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 507 B
build/block-library/blocks/media-text/style.css 505 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 712 B
build/block-library/blocks/navigation-link/editor.css 711 B
build/block-library/blocks/navigation-link/style-rtl.css 115 B
build/block-library/blocks/navigation-link/style.css 115 B
build/block-library/blocks/navigation-submenu/editor-rtl.css 296 B
build/block-library/blocks/navigation-submenu/editor.css 295 B
build/block-library/blocks/navigation/editor-rtl.css 2.35 kB
build/block-library/blocks/navigation/editor.css 2.36 kB
build/block-library/blocks/navigation/interactivity.min.js 978 B
build/block-library/blocks/navigation/style-rtl.css 2.21 kB
build/block-library/blocks/navigation/style.css 2.2 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 401 B
build/block-library/blocks/page-list/editor.css 401 B
build/block-library/blocks/page-list/style-rtl.css 175 B
build/block-library/blocks/page-list/style.css 175 B
build/block-library/blocks/paragraph/editor-rtl.css 174 B
build/block-library/blocks/paragraph/editor.css 174 B
build/block-library/blocks/paragraph/style-rtl.css 279 B
build/block-library/blocks/paragraph/style.css 281 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/editor-rtl.css 96 B
build/block-library/blocks/post-comments-form/editor.css 96 B
build/block-library/blocks/post-comments-form/style-rtl.css 508 B
build/block-library/blocks/post-comments-form/style.css 508 B
build/block-library/blocks/post-date/style-rtl.css 61 B
build/block-library/blocks/post-date/style.css 61 B
build/block-library/blocks/post-excerpt/editor-rtl.css 71 B
build/block-library/blocks/post-excerpt/editor.css 71 B
build/block-library/blocks/post-excerpt/style-rtl.css 141 B
build/block-library/blocks/post-excerpt/style.css 141 B
build/block-library/blocks/post-featured-image/editor-rtl.css 588 B
build/block-library/blocks/post-featured-image/editor.css 586 B
build/block-library/blocks/post-featured-image/style-rtl.css 319 B
build/block-library/blocks/post-featured-image/style.css 319 B
build/block-library/blocks/post-navigation-link/style-rtl.css 153 B
build/block-library/blocks/post-navigation-link/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 314 B
build/block-library/blocks/post-template/style.css 314 B
build/block-library/blocks/post-terms/style-rtl.css 96 B
build/block-library/blocks/post-terms/style.css 96 B
build/block-library/blocks/post-time-to-read/style-rtl.css 69 B
build/block-library/blocks/post-time-to-read/style.css 69 B
build/block-library/blocks/post-title/style-rtl.css 100 B
build/block-library/blocks/post-title/style.css 100 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 135 B
build/block-library/blocks/pullquote/editor.css 135 B
build/block-library/blocks/pullquote/style-rtl.css 335 B
build/block-library/blocks/pullquote/style.css 335 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 221 B
build/block-library/blocks/query-pagination/editor.css 211 B
build/block-library/blocks/query-pagination/style-rtl.css 288 B
build/block-library/blocks/query-pagination/style.css 284 B
build/block-library/blocks/query-title/style-rtl.css 63 B
build/block-library/blocks/query-title/style.css 63 B
build/block-library/blocks/query/editor-rtl.css 450 B
build/block-library/blocks/query/editor.css 449 B
build/block-library/blocks/quote/style-rtl.css 222 B
build/block-library/blocks/quote/style.css 222 B
build/block-library/blocks/quote/theme-rtl.css 223 B
build/block-library/blocks/quote/theme.css 226 B
build/block-library/blocks/read-more/style-rtl.css 132 B
build/block-library/blocks/read-more/style.css 132 B
build/block-library/blocks/rss/editor-rtl.css 149 B
build/block-library/blocks/rss/editor.css 149 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 178 B
build/block-library/blocks/search/editor.css 178 B
build/block-library/blocks/search/style-rtl.css 587 B
build/block-library/blocks/search/style.css 584 B
build/block-library/blocks/search/theme-rtl.css 114 B
build/block-library/blocks/search/theme.css 114 B
build/block-library/blocks/search/view.min.js 531 B
build/block-library/blocks/separator/editor-rtl.css 146 B
build/block-library/blocks/separator/editor.css 146 B
build/block-library/blocks/separator/style-rtl.css 234 B
build/block-library/blocks/separator/style.css 234 B
build/block-library/blocks/separator/theme-rtl.css 194 B
build/block-library/blocks/separator/theme.css 194 B
build/block-library/blocks/shortcode/editor-rtl.css 323 B
build/block-library/blocks/shortcode/editor.css 323 B
build/block-library/blocks/site-logo/editor-rtl.css 754 B
build/block-library/blocks/site-logo/editor.css 754 B
build/block-library/blocks/site-logo/style-rtl.css 203 B
build/block-library/blocks/site-logo/style.css 203 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 116 B
build/block-library/blocks/site-title/editor.css 116 B
build/block-library/blocks/site-title/style-rtl.css 57 B
build/block-library/blocks/site-title/style.css 57 B
build/block-library/blocks/social-link/editor-rtl.css 184 B
build/block-library/blocks/social-link/editor.css 184 B
build/block-library/blocks/social-links/editor-rtl.css 674 B
build/block-library/blocks/social-links/editor.css 673 B
build/block-library/blocks/social-links/style-rtl.css 1.43 kB
build/block-library/blocks/social-links/style.css 1.42 kB
build/block-library/blocks/spacer/editor-rtl.css 348 B
build/block-library/blocks/spacer/editor.css 348 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 433 B
build/block-library/blocks/table/editor.css 433 B
build/block-library/blocks/table/style-rtl.css 645 B
build/block-library/blocks/table/style.css 644 B
build/block-library/blocks/table/theme-rtl.css 146 B
build/block-library/blocks/table/theme.css 146 B
build/block-library/blocks/tag-cloud/style-rtl.css 251 B
build/block-library/blocks/tag-cloud/style.css 253 B
build/block-library/blocks/template-part/editor-rtl.css 403 B
build/block-library/blocks/template-part/editor.css 403 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/term-description/style-rtl.css 111 B
build/block-library/blocks/term-description/style.css 111 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 99 B
build/block-library/blocks/verse/style.css 99 B
build/block-library/blocks/video/editor-rtl.css 552 B
build/block-library/blocks/video/editor.css 555 B
build/block-library/blocks/video/style-rtl.css 174 B
build/block-library/blocks/video/style.css 174 B
build/block-library/blocks/video/theme-rtl.css 126 B
build/block-library/blocks/video/theme.css 126 B
build/block-library/classic-rtl.css 179 B
build/block-library/classic.css 179 B
build/block-library/common-rtl.css 1.1 kB
build/block-library/common.css 1.1 kB
build/block-library/editor-elements-rtl.css 75 B
build/block-library/editor-elements.css 75 B
build/block-library/editor-rtl.css 12.2 kB
build/block-library/editor.css 12.1 kB
build/block-library/elements-rtl.css 54 B
build/block-library/elements.css 54 B
build/block-library/index.min.js 201 kB
build/block-library/interactivity/runtime.min.js 2.71 kB
build/block-library/interactivity/vendors.min.js 8.2 kB
build/block-library/reset-rtl.css 478 B
build/block-library/reset.css 478 B
build/block-library/style-rtl.css 13.5 kB
build/block-library/style.css 13.5 kB
build/block-library/theme-rtl.css 686 B
build/block-library/theme.css 691 B
build/block-serialization-default-parser/index.min.js 1.12 kB
build/block-serialization-spec-parser/index.min.js 2.87 kB
build/blocks/index.min.js 50.8 kB
build/commands/index.min.js 14.9 kB
build/commands/style-rtl.css 827 B
build/commands/style.css 827 B
build/components/index.min.js 231 kB
build/components/style-rtl.css 11.8 kB
build/components/style.css 11.8 kB
build/compose/index.min.js 12.1 kB
build/core-commands/index.min.js 2.12 kB
build/core-data/index.min.js 15.7 kB
build/customize-widgets/index.min.js 12 kB
build/customize-widgets/style-rtl.css 1.38 kB
build/customize-widgets/style.css 1.38 kB
build/data-controls/index.min.js 640 B
build/data/index.min.js 8.3 kB
build/date/index.min.js 40.4 kB
build/deprecated/index.min.js 451 B
build/dom-ready/index.min.js 324 B
build/dom/index.min.js 4.63 kB
build/edit-post/classic-rtl.css 544 B
build/edit-post/classic.css 545 B
build/edit-post/index.min.js 34.1 kB
build/edit-post/style-rtl.css 7.58 kB
build/edit-post/style.css 7.57 kB
build/edit-site/index.min.js 69.9 kB
build/edit-site/style-rtl.css 11.6 kB
build/edit-site/style.css 11.6 kB
build/edit-widgets/index.min.js 16.8 kB
build/edit-widgets/style-rtl.css 4.53 kB
build/edit-widgets/style.css 4.53 kB
build/editor/index.min.js 44.7 kB
build/editor/style-rtl.css 3.54 kB
build/editor/style.css 3.53 kB
build/element/index.min.js 4.8 kB
build/escape-html/index.min.js 537 B
build/format-library/index.min.js 7.57 kB
build/format-library/style-rtl.css 554 B
build/format-library/style.css 553 B
build/hooks/index.min.js 1.55 kB
build/html-entities/index.min.js 448 B
build/i18n/index.min.js 3.58 kB
build/is-shallow-equal/index.min.js 527 B
build/keyboard-shortcuts/index.min.js 1.71 kB
build/keycodes/index.min.js 1.84 kB
build/list-reusable-blocks/index.min.js 2.13 kB
build/list-reusable-blocks/style-rtl.css 836 B
build/list-reusable-blocks/style.css 836 B
build/media-utils/index.min.js 2.9 kB
build/notices/index.min.js 948 B
build/plugins/index.min.js 1.84 kB
build/preferences-persistence/index.min.js 1.84 kB
build/preferences/index.min.js 1.24 kB
build/primitives/index.min.js 941 B
build/priority-queue/index.min.js 1.52 kB
build/private-apis/index.min.js 939 B
build/react-i18n/index.min.js 696 B
build/react-refresh-entry/index.min.js 8.44 kB
build/react-refresh-runtime/index.min.js 7.31 kB
build/redux-routine/index.min.js 2.7 kB
build/reusable-blocks/index.min.js 2.21 kB
build/reusable-blocks/style-rtl.css 243 B
build/reusable-blocks/style.css 243 B
build/rich-text/index.min.js 10.7 kB
build/router/index.min.js 1.77 kB
build/server-side-render/index.min.js 2.02 kB
build/shortcode/index.min.js 1.39 kB
build/style-engine/index.min.js 1.42 kB
build/token-list/index.min.js 582 B
build/url/index.min.js 3.57 kB
build/vendors/inert-polyfill.min.js 2.48 kB
build/vendors/react-dom.min.js 41.8 kB
build/vendors/react.min.js 4.02 kB
build/viewport/index.min.js 1.04 kB
build/warning/index.min.js 268 B
build/widgets/index.min.js 7.16 kB
build/widgets/style-rtl.css 1.15 kB
build/widgets/style.css 1.16 kB
build/wordcount/index.min.js 1.02 kB

compressed-size-action

@andrewserong andrewserong force-pushed the try/add-position-visualizer branch from fa17664 to ae867f6 Compare April 13, 2023 06:55
}

return (
<BlockPopover
Copy link
Contributor Author

@andrewserong andrewserong Apr 13, 2023

Choose a reason for hiding this comment

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

Just a note: To fix the issue where the popover goes off the edge of the screen, it might be worth experimenting with Popover instead and then pass it a rect (or getBoundingClientRect() function) so that we can ensure it's only rendering over the visible area of the page. I.e. treat this a little bit like the drop indicators.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Potential fix for this issue in #49978

@andrewserong
Copy link
Contributor Author

Update:

@andrewserong
Copy link
Contributor Author

andrewserong commented Apr 24, 2023

In f2f4682, I've fixed up the dimensions of the BlockPopover so that when the browser window is resized (or when scrollbars appear) then it gets recalculated. If it turns out that this shouldn't be behaviour for all BlockPopovers, then we can always move the logic into the PositionVisualizer instead. For now, I'll leave it where it is, and we can look at it in more detail once this PR is ready for review.

Edit: it could possibly be better to use a useResizeObserver instead, but I believe that would need to be output around the element that's being targeted, which we don't really have access to in React in the current context... but depending on feedback, it could be worth attempting to refactor to use that instead.

@github-actions
Copy link

github-actions bot commented Apr 24, 2023

Flaky tests detected in b9e7b37.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/5285159526
📝 Reported issues:

@andrewserong andrewserong force-pushed the try/add-position-visualizer branch from f2f4682 to 9e42a8b Compare April 26, 2023 03:53
@andrewserong
Copy link
Contributor Author

This is getting closer to a testable state, but one issue I ran into is that the top position isn't aware of any other sticky elements on the page. So, for a site that has a sticky header and also wants other areas to be sticky, it doesn't automatically detect a correct top value to use that would be pleasing, and the non-root-sticky element winds up going above the sticky header:

2023-04-26.15.02.53.mp4

In a long post that contains sticky headings, this behaviour of sitting on top of the other sticky element could actually be desirable.

What I'm wonder now, is whether we might want to give the user the ability to set a top offset value for the sticky position?

@andrewserong andrewserong marked this pull request as ready for review April 26, 2023 06:48
@andrewserong andrewserong requested a review from ellatrix as a code owner April 26, 2023 06:48
@andrewserong
Copy link
Contributor Author

Update: this PR should be ready for review now — it's an experimental idea to see if adding text, plus a visualizer for sticky positioning will help improve the UX for sticky positioning at non-root positions.

Feedback and alternate ideas are very welcome! For example, we could do a lot of adjustment to how the sticky visualizer appears, tweak text, etc.

I noticed one potential block, which is that if the site uses sticky position for its header, then the element that's set to sticky doesn't know that it should have a top value to steer clear of it. A question for reviewers is whether or not re-enabling in non-root positions will necessitate having a UI control over the top position or offset.

@jasmussen
Copy link
Contributor

Thanks for considering this. It's an excellent instinct, the use case for non-root locations is valid, the video is helpful, and the example code even moreso. Here's a GIF just showing me experiencing the same as your demo:

testing

The key take-away here is shown in this image:

Screenshot 2023-04-26 at 09 25 35

The light blue border shown in the canvas here is meant to denote the parent container, so that it's clear what the block sticks to.

This actually reminds me a fair bit of some similar explorations we've had in the past, in general around template parts, ancestors, etc, having explored dotted lines or similar. #44774 and #44775 are tangentially related. Because these block outlines have come up many times in the past, I'd appreciate input from @jameskoster or @SaxonF, because when to show outlines and what they should look like is something we need to get right.

Is contextuality like suggested here the key? Should the outline be shown when the Sticky option is focused or interacted with, and ten fade out? Or should it show when the block is selected? Should it be shown when a block is hovered? Should it be a dotted line? Should it be something else, like dimming non-selected blocks, more like spotlight mode?

@jameskoster
Copy link
Contributor

I'm curious about the motivation to indicate the sticky block container on the canvas? It will always be the direct ancestor, so it doesn't seem super useful to me. I am likely missing something though.

Overall I wonder if it would be better expressed in List View. I think we tried some explorations around that before but didn't land anything yet.

@andrewserong
Copy link
Contributor Author

Thanks for the feedback and suggestions @jasmussen and @jameskoster!

I'm curious about the motivation to indicate the sticky block container on the canvas? It will always be the direct ancestor, so it doesn't seem super useful to me. I am likely missing something though.

Good question — when we first landed the sticky position support, based on user feedback, it turned out that it was confusing for folks that when they set a non-root Group block to Sticky, they thought it'd stick to the top of the page, and the behaviour that it sticks to the direct ancestor wasn't clear. Based on that feedback, we removed the non-root sticky support until the UX could be improved (here's a wrap up comment from that time).

So, the problem to solve is how do we make it clear to a user what's happening when they set a block to sticky? My current hunch is that the best bet is to provide a visual clue within the editor canvas so that a user can see the visual area that defines how sticky will work. Highlighting the area of the parent in relation to the currently selected block seems like a good way to do it to me, but I'm sure there'd be other options!

Overall I wonder if it would be better expressed in List View. I think we tried some explorations around that before but didn't land anything yet.

We haven't tried anything that flags which parent it relates to yet, I don't think. There's an open PR (#49122) to flag the status of sticky, but not the relationship between the sticky block and its parent. While improving things in the list view is a good idea, my feeling is that we'll need something a little more prominent in the editor canvas in order for the feature not to feel broken for users that set sticky in nested blocks but don't really know what's going on.

Is contextuality like suggested here the key? Should the outline be shown when the Sticky option is focused or interacted with, and ten fade out? Or should it show when the block is selected? Should it be shown when a block is hovered? Should it be a dotted line? Should it be something else, like dimming non-selected blocks, more like spotlight mode?

These are exactly the kinds of questions I was hoping for! I think showing the context for the user is key, similar to how we have padding and margin visualizers to help users understand those concepts.

Determining exactly when to show the visualizer, when to hide it, and what it should look like are all great things to explore. Let me know if anyone has ideas about how this might look, and I'm happy to continue hacking around 🙂

},
[ clientId ]
);

const blockInformation = useBlockDisplayInformation( firstParentClientId );
const stickyHelpText =
allowSticky && value === 'sticky' && blockInformation
Copy link
Member

Choose a reason for hiding this comment

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

Would it be worth checking against STICKY_OPTION.value?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That'd be neater, yes — I'll update. Thanks for spotting it!

@ramonjd
Copy link
Member

ramonjd commented May 26, 2023

then the one in post content will visually sit on top of both the sticky header, and the navigation block's overlay, due to the stacking context.

For the mobile menu, would it be dodgy to hide is-position-sticky when the body has a class of has-modal-open ?

If a Group block is a wrapping block for a template part (i.e. the immediate parent) then give it a slightly higher z-index (say, 15 instead of 10)

This sounds like a reasonable and non-invasive first approach for now. How long term would this be? I'm thinking backwards compatibility when and if we add z-index to block supports. I suppose 15 could become the fallback value for immediate children of templates.

Having said all that, I've tested this given those constraints and I think it's in good shape. Stickyness in most cases works as I expect and the visualizer appears when I hover over the stick item in the drop down only.

@jasmussen
Copy link
Contributor

This is cool, this could work:

sticky

Can the blue indicator be below the sticky block? I.e. indicating only the parent? Not crucial, but would be a nice little nod.

This one:

Screenshot 2023-05-26 at 08 29 44

The gray hover state for an item here is very dark and means the contrast isn't good. I imagine it's a separate issue with the dropdown control, just like the 2px focus state, but mentioning here just in case it's local.

Would it be possible to also show the highlight if you hover the "Sticky" state in this dropdown? I.e. imagine it's set to default, and you hover the sticky state to show the parent container it'll stick to? Also not crucial at all, if it's hacky or even minimally hard to implement, not worth it, just wondering.

I would love a check from @jameskoster but on my side, especially if we can put the highlight below the sticky block, I could get behind this!

@andrewserong
Copy link
Contributor Author

Thanks for taking this for another spin, Joen!

I imagine it's a separate issue with the dropdown control, just like the 2px focus state, but mentioning here just in case it's local.

Yes, I think that issue is with the control, but it'd be a good one to improve.

Would it be possible to also show the highlight if you hover the "Sticky" state in this dropdown?

Unfortunately the CustomSelectControl doesn't let us pass event handlers down to each of the individual options. It'd be cool if it did, though — happy to look into extending that component either separately or in a follow-up so that it can allow events.

Can the blue indicator be below the sticky block? I.e. indicating only the parent? Not crucial, but would be a nice little nod.

Oh, good idea. I'll have a play with that when I'm back next week. One potential issue is that if there isn't much content yet, then hovering over the dropdown might not show anything if we set the visualizer to be underneath the sticky block. So even if it doesn't look very pretty, it might still be useful for it to be overlaid so that it's clear when the sticky region is very minimal? Just a thought, but I don't feel too strongly about it.

The other challenge is that depending on how the popover works, it might be tricky to get it to display underneath 🤔... either way, I'll play with it and report back 🙂

@jameskoster
Copy link
Contributor

In terms of functionality this is working well, but the visualiser doesn't quite hit the mark for me. It may be subjective, but this treatment doesn't communicate the behavior in an intuitive way. Is it vital? Could we explore this detail separately?

@andrewserong
Copy link
Contributor Author

Thanks for re-testing!

but the visualiser doesn't quite hit the mark for me. It may be subjective, but this treatment doesn't communicate the behavior in an intuitive way. Is it vital? Could we explore this detail separately?

Unfortunately, I think having some form of visualisation is probably a requirement for reintroducing non-root sticky position blocks. Feedback when we initially introduced sticky position was that without having some form of visualisation, users unfamiliar with the CSS property would find the behaviour confusing that sticky means stick-to-parent, and I'm not sure if the help text is quite enough to communicate that on its own. I think @mtias and @richtabor might have been some of the folks who gave that feedback, from memory?

I'm happy to keep chipping away at this PR and/or try out other ideas. Also happy to merge in a reduced version of this PR that enables non-root sticky positioning + the help text, without the visualizer, if we can get consensus 🙂

@mtias
Copy link
Member

mtias commented May 31, 2023

Can we try adding some visualization to the list view when this is set? (An icon with a tooltip, perhaps, or a badge that says "sticky".)

@andrewserong
Copy link
Contributor Author

Can we try adding some visualization to the list view when this is set? (An icon with a tooltip, perhaps, or a badge that says "sticky".)

Yes, we started exploring this back in #49122 but wound up being blocked by some work that's now landed to improve the accessibility of how blocks are read out in the list view. That work has landed now, so it should be ready for a rebase. I'll dust it off tomorrow.

@ndiego
Copy link
Member

ndiego commented Jun 12, 2023

Hey @andrewserong, this is looking great! Are we aiming for 6.3 with this? #47043 is on the 6.3 Project Board, so I wasn't sure. If so, I'll add this PR to the board as well. Thanks!

@andrewserong
Copy link
Contributor Author

Are we aiming for 6.3 with this? #47043 is on the 6.3 Project Board, so I wasn't sure. If so, I'll add this PR to the board as well.

Thanks for the ping! Yes, my hope is to land both this and #49122 as the main parts of the #47043 tracking issue for 6.3. It currently depends on whether we can reach a good balance in terms of design and functionality in time, but that is currently my aim.

@ndiego
Copy link
Member

ndiego commented Jun 13, 2023

Great, thanks @andrewserong. I updated the board accordingly.

@andrewserong andrewserong changed the title Sticky Position: Try re-enabling non-root sticky position, and add a visualizer to define sticky area Sticky Position: Try re-enabling non-root sticky position Jun 16, 2023
@andrewserong andrewserong force-pushed the try/add-position-visualizer branch from bbae9fa to b9e7b37 Compare June 16, 2023 01:16
@andrewserong
Copy link
Contributor Author

Update: I have pared this PR back to just re-enabling non-root sticky positions, and the inclusion of the help text, and removed the visualizer for now. We also have #49122 ready for review, which adds the sticky icon to the list view.

There is still an outstanding issue for sites that have sticky headers and also use sticky blocks elsewhere in the post content, as flagged by @tellthemachines earlier in #49321 (review) — that issue technically exists irrespective of this PR, so I would lean toward looking into fixing that separately. I believe the main way to fix that would be to either allow individual control over z-index values, or add some clever logic that adjusts the z-index for the sticky block based on whether or not it contains a template part. Either way, I think it's best to look into fixes separately if we can.

I think this PR should be ready for a final review now. To recap, the PR now does the following:

  • Allow non-root positions
  • Add help text beneath the position control when Sticky is set and the block has a parent, to describe how the block will stick to its parent

Thanks again for the feedback, everyone! 🙇

Copy link
Member

@ramonjd ramonjd left a comment

Choose a reason for hiding this comment

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

Tested again in Chrome, Safari and FF

I think we're in a good spot and ready for further iterations. Thanks for "sticking" with this one!

2023-06-16.13.12.13.mp4

@andrewserong
Copy link
Contributor Author

Thanks for reviewing @ramonjd!

Since we have clearer ideas now about which visualisation aspects we do or don't want (no the visualiser, yes to adding an icon in the list view), and that the other changes in this PR appeared to be non-controversial (adding in help text, re-enabling non-root positions), I'll merge this one in now.

If there are any objections or issues over the weekend, I can spin up a revert on Monday — this PR only really changes whether or not the control is visible in non-root positions, so it'd be easy to return to the previous state, with plenty of time before the next Gutenberg RC.

Thanks again for all the input, everyone!

@andrewserong andrewserong merged commit b6fb0a6 into trunk Jun 16, 2023
@andrewserong andrewserong deleted the try/add-position-visualizer branch June 16, 2023 03:56
@github-actions github-actions bot added this to the Gutenberg 16.1 milestone Jun 16, 2023
sethrubenstein pushed a commit to pewresearch/gutenberg that referenced this pull request Jul 13, 2023
…49321)

* Sticky Position: Try re-enabling non-root sticky position, and add a visualizer to define sticky area

* Fix whitespace

* Ensure the position visualizer does not interfere with the ability to select inner blocks

* Ensure resizing the block editor will update the block popover dimensions

* Try simplifying the display logic so it always shows the visualizer if the block is selected

* Small code quality tweaks

* Try dotted outline, subtle display on focus and hover label

* Fix help text and spacing

* Update visualizer to only display on hover

* Remove visualizer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Design Tools Tools that impact the appearance of blocks both to expand the number of tools and improve the experi [Type] Experimental Experimental feature or API.
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

Position "sticky" - Gutenberg 15.1.0 killed sidebar option
7 participants