Skip to content

Fixed / Sticky position follow up tasks #47043

Open

Description

@andrewserong

Related:

An initial implementation of sticky position block support was added and enabled on the Group block in: #46142. This issue lists follow-up tasks now that the initial PR has landed. Some of these could be split out into their own issues depending on complexity.

Current state of sticky position support

The screengrab below demos wrapping a header template part in a group block, setting that group block to full width, then setting that group block to "sticky":

header-wrapped-in-sticky-group.mp4

Follow-up tasks

Related tasks and issues

These tasks might not be immediately related, but in terms of UX and features, there could be some overlap to explore in the implementation:

Activity

  1. added
    [Block] Group
    [Feature] Design Tools
    [Block] Template Part
    [Feature] Layout
    [Type] Tracking Issue
    on Jan 10, 2023
  2. jameskoster commented on Jan 11, 2023

    @jameskoster
    Contributor

    e.g. is it possible to achieve without having to wrap the header template part in a sticky Group block?

    I've said this elsewhere, but I don't think this is something to be avoided. My opinion is that the document should decide the position of its blocks rather than the blocks themselves. Otherwise it prohibits things like template parts or reusable blocks from being conditionally sticky, unless we build a complex position over-ride UI which probably is something to avoid.

    We can still simplify the process though. Perhaps there's an option in the template part toolbar (ellipsis menu?) to make it sticky, which is essentially a shortcut to wrap it in a container with position: sticky applied.

    Which leads me neatly to:

    Update List View to flag in the UI when a block has a position value set

    It might be interesting to try a simple prefix (or suffix) added to the block name, denoting non-default position values. "Group (sticky)", for example. We could even consider surfacing this as a variation in the Inserter to enable quick creation of sticky regions in a document.

  3. priethor commented on Jan 12, 2023

    @priethor
    Contributor

    I've said this elsewhere, but I don't think this is something to be avoided. My opinion is that the document should decide the position of its blocks rather than the blocks themselves.

    That's good reasoning. On the other hand, it could also be applied to settings like width and height, as a reusable block will have a different width within a full-width container vs. when placed inside a column. For now, I think we might want to not open that can of worms because if we want the position to be set at the document level, we would need to review what other settings should follow the same logic.

  4. jameskoster commented on Jan 12, 2023

    @jameskoster
    Contributor

    The challenge we face with any such setting is clarity around where/when they will be applied. For example we used to have a background color option for template parts. This constantly tripped people up, because they'd edit a template, select the Header, change the background, and expect that change to be applied to the template part globally.

    We'd run into that problem again here. That's not to say it's insurmountable. Just that we'd need to consider a 'local overrides' UI with resetting, or some foundational changes to the inline editing experience that draws clearer lines between document + template part / reusable block (#43608 might help).

  5. apeatling commented on Jan 12, 2023

    @apeatling
    Contributor

    My vote would go for allowing block supports on template parts, because:

    • This follows the most logical path for a user based on how everything else works. Select the template part like a block, set to sticky.
    • It allows a user to decide which templates a template part is sticky on.
    • It avoids any extra UI, wrapping it in a group block will be unexpected, muddy block selection, and users will wonder how it got there.
    • You can be super selective on which block supports a template part utilizes -- just leave out things like background color that have confused in the past. (Edit: this doesn't solve the global vs local confusion)
    • Maybe there could be a way in the future to set the default supports values (like sticky) by a pattern author when being inserted within a template part?

    I'm probably missing some important details and nuance. :)

  6. andrewserong commented on Jan 13, 2023

    @andrewserong
    ContributorAuthor

    Great discussion here, folks! I love the idea of exposing the position controls at the template part block level in terms of making it that accessible / discoverable to a user. However, @jameskoster makes a good point that this runs into issues to do with the local versus global nature of editing template parts. That is, the position value will only be set on the particular instance of the template part within the template being edited, and won't be applied globally to the header template part across all templates. Figuring out the desired UX there (and technical implementation if we went with document-level attributes) might be quite tricky, too... 🤔

    To give us a little more to play with to come up with a direction forward, I've opened up a PR to opt the template part block in to the position support over in #47133 — this PR isn't intended to land, but I thought I'd open it up to hopefully have something to aid the discussion about how we should proceed. My first impression is that it feels pretty good to use, but as in the reasoning behind the earlier removal of styles from the template part block (in #36571), I can definitely see how a user would expect their changes to apply across templates, and be confused as to why it isn't. I could imagine that being a blocker.

  7. fabiankaegy commented on Jan 13, 2023

    @fabiankaegy
    Member

    I was just playing with the position control and struggled to figure out how to make my header template part sticky. So the current flow is creating a bad experience for someone that doesn't necessarily understand the technical details.

    I really like the idea of exposing the position controls on the template part as well. I think that would help a lot. Additionally, it might be a good enhancement to hide the sticky position setting in areas where it doesn't do anything. If we know that setting it on the wrapping group inside of a template part it isn't ideal that the setting is even available.

  8. andrewserong commented on Jan 17, 2023

    @andrewserong
    ContributorAuthor

    Thanks for the continued feedback, everyone! As another potential idea for how we might improve the UX here, I've opened up a PR to explore adding a warning notice next to the Sticky position control if the group block is at a non-root level (a little bit like how we have contrast checker warnings). The PR is here: #47207

    Using Sticky positioning for things that are not site-wide headers and footers can be quite useful (I see this a lot on real estate websites, or on some sites with contact info areas that scroll for only a particular section), however it's likely not the common use case (which we're imagining to be sticky headers). I'm wondering if the additional notice when the block is not at the root level could help nudge users in the right direction / help with the UX there, irrespective of whether or not we wind up enabling sticky support for the template block.

    Another option could be to hide the Sticky position controls altogether if the block is not set to the root of the document — personally, I'd prefer to avoid this if possible, since it's quite cool to be able to create sticky areas within a larger document, and it'd be nice to make that available if we can. Happy for any feedback / ideas / discussion over in #47207 if folks are interested.

  9. richtabor commented on Jan 17, 2023

    @richtabor
    Member

    I was just playing with the position control and struggled to figure out how to make my header template part sticky. So the current flow is creating a bad experience for someone that doesn't necessarily understand the technical details.

    I agree. It's not intuitive and also buries the Header template part in List view.

    And if buried, the template doesn't show up in the "Template" inspector sidebar.

    CleanShot 2023-01-17 at 15 48 23@2x

  10. 22 remaining items

  11. apeatling commented on Apr 24, 2023

    @apeatling
    Contributor

    These real usage examples are great and help keep the development grounded. Also gives good ideas for demoing the new functionality. :)

  12. andrewserong commented on Apr 26, 2023

    @andrewserong
    ContributorAuthor

    I have a PR open in #49321 to explore re-enabling non-root sticky position, and adding a visualizer to define the sticky area visually. It's a little experimental, but very happy for feedback and/or ideas on the PR!

  13. moved this from ❓ Triage to 🏗️ In Progress in WordPress 6.3.x Editor Taskson Jun 13, 2023
  14. ndiego commented on Jul 14, 2023

    @ndiego
    Member

    @andrewserong can I remove this from the 6.3 Project Board, or would you prefer we keep it? Just trying to tidy up the board 😅

  15. andrewserong commented on Jul 16, 2023

    @andrewserong
    ContributorAuthor

    Thanks for the ping @ndiego! I've removed this from the project board now as the PRs for 6.3 have all been merged (e.g. #49321 and #49122) 🙂

  16. apeatling commented on Jul 17, 2023

    @apeatling
    Contributor

    Nice work so far on this @andrewserong, lots of good changes for folks upgrading to 6.3. 👍

  17. miklb commented on Apr 25, 2024

    @miklb

    Ideally, you'd edit the template part, add sticky positioning, and the stickiness would be applied to the parent template part across the site.

    Kind of a tall order, but is there way to detect and apply the positioning to the template part, if the stickied block is a direct child of a template part block?

    Seems like there should be a way using:has but I haven't dug in deep. Just experienced this issue and the counter intuitiveness. Editing every template that uses a header if you want it sticky site wide seems a bit much.

  18. SporeProductions commented on Nov 25, 2024

    @SporeProductions

    Still not working in Twenty Twenty-Five

  19. lmisch commented on Feb 3, 2025

    @lmisch

    +1

  20. paaljoachim commented on Sep 12, 2025

    @paaljoachim
    Contributor

    It would be helpful with an update here.
    I am not seeing sticky work with Twenty Twenty five theme.

    I was able to get it to work with this code:
    `/* Sticky header */
    header:has(>.is-position-sticky) {
    position: sticky;
    top: calc( 0px + var( --wp-admin--admin-bar--height, 0px ) );
    z-index: 100;
    }

    @media (max-width: 600px) {
    header:has(>.is-position-sticky) {
    top: 0;
    }
    }`

  21. andrewserong commented on Sep 15, 2025

    @andrewserong
    ContributorAuthor

    Hi folks, as described in the issue, Sticky does work in Twenty Twenty Five theme, but the feature currently requires the Header to be wrapped in a root-level Group block that is set to sticky. Here's how that looks (basically the same as in the video in the issue description):

    Image

    The task for allowing template parts to be set to sticky hasn't been implemented yet, I believe due to overall concerns about attaching styles directly to template parts. It's this one from the to-do list:

    Improve the experience for setting a sticky or fixed header, e.g. is it possible to achieve without having to wrap the header template part in a sticky Group block? Related issue: #50617

    @paaljoachim in the meantime, if you're wanting to allow blocks within the header to affect the stickiness of the header itself, the CSS you've described should do the job. It's a bit opinionated, so makes sense to me if individual sites or themes add that kind of CSS if they so choose, rather than including it directly in core themes.

    Now that :has() has wider browser support, though, it could be worth revisiting how the Sticky position support works if anyone's interested in digging in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    [Block] Group[Block] Template Part[Feature] Design Tools[Feature] Layout[Type] Tracking Issue

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions