Make WordPress Core

Opened 15 months ago

Closed 15 months ago

Last modified 15 months ago

#57618 closed enhancement (fixed)

Introduce sticky position block support

Reported by: andrewserong's profile andrewserong Owned by: davidbaumwald's profile davidbaumwald
Milestone: 6.2 Priority: normal
Severity: normal Version:
Component: Editor Keywords: gutenberg-merge has-patch has-unit-tests commit
Focuses: Cc:


In the Gutenberg plugin, a position block support feature was introduced last year, that allows a Group block to be set to a "sticky" position, meaning that when the page scrolls, the block will stick to the top of the window.

It would be good to backport this feature for the WP 6.2 release. While the feature is spread across JS and PHP code, it should be possible to land most of the PHP implementation in advance of the JS packages update for core.

The original feature landed in Gutenberg across the following PRs:

Change History (10)

This ticket was mentioned in PR #3973 on WordPress/wordpress-develop by @andrewserong.

15 months ago

  • Keywords has-patch has-unit-tests added

This PR backports the PHP parts of the new sticky position block support, and is a follow-on from

Backports the PHP parts of the following PRs:

Notes on this backport:

  • The backport deviates from Gutenberg trunk in one way: fixed position type is excluded from the appearance tools opt-in: this is because fixed positioning isn't being opted-in for the Group block and isn't ready to be used as a default opt-in. The code paths exist for fixed positioning as it will be supported in the future, but for now, sticky is the only one exposed by default. (The overall block support should still support it as a valid value, though)
  • The styling output while logged in depends on the JS packages update, as it will include the CSS changes in #47665, so while testing this PR you might notice an odd styling issue while logged in. This should be resolved once the package update lands.
  • With the above caveat shouldn't really be an issue though, as there is no way for a user to set a group block to sticky without the JS packages landing. This PR is to land the required PHP changes in advance of that.


| While logged in (CSS variable that's included in JS packages update isn't yet output in this PR, once it is the sticky block will sit below the admin bar) | While not logged in (correct) |
| --- | --- |
| | |

Testing instructions:

  • In the Group block's block.json file add a "position": { "sticky": true } object under "supports" (Note: for this change to propagate in your testing, you might need to rebuild the block JSON cache locally).
  • Create a post and add a bunch of paragraphs.
  • Insert the below markup at the beginning of the post (this is Group block markup with the appropriate position style object to sticky to top).
  • Publish the post, and on the site frontend, the group block should stick to the top of the screen once it has been scrolled past the top of the screen (the block sticks to the scrollable area of its container)

Group block markup for testing purposes:


<div class="wp-block-group has-background" style="background-color:#f2aeae;padding-top:1em;padding-right:1em;padding-bottom:1em;padding-left:1em">
<p>A paragraph in a sticky group</p>


Trac ticket:

#2 @hellofromTonya
15 months ago

  • Milestone changed from Awaiting Review to 6.2
  • Version trunk deleted

#3 @flixos90
15 months ago

  • Owner set to flixos90
  • Status changed from new to reviewing

I already reviewed (almost good to go from my perspective), and I'm happy to commit this once it's ready.

@andrewserong commented on PR #3973:

15 months ago

Thanks for reviewing @felixarntz!

Does this have to wait for the JS package update, or can it be committed to core before already?

This can be committed before the JS package update, since this PR doesn't opt any of the blocks into the new control, so it doesn't expose anything to a user. I think it's preferable to land this PR first, so that when the JS packages update happens, the PHP parts will already be in place.

#5 @hellofromTonya
15 months ago

  • Keywords commit added

As @flixos90 has approved for commit and @andrewserong confirmed it can be committed prior to package updates, marking for commit.

This ticket was mentioned in Slack in #core by costdev. View the logs.

15 months ago

#7 @davidbaumwald
15 months ago

  • Owner changed from flixos90 to davidbaumwald

#8 @davidbaumwald
15 months ago

  • Resolution set to fixed
  • Status changed from reviewing to closed

In 55285:

Editor: Introduce sticky position block support.

In the Gutenberg plugin, a position block support feature was introduced last year, that allows a Group block to be set to a "sticky" position, meaning that when the page scrolls, the block will stick to the top of the window.

This change merges the "sticky" position feature for blocks introduced in Gutenberg 15.0.

Props andrewserong, flixos90, mukesh27.
Fixes #57618.

#10 @davidbaumwald
15 months ago

In 55286:

Editor: svn add new files missed in [55285].

Follow-up to [55285].

See #57618.

Note: See TracTickets for help on using tickets.