Skip to content

fix(block-editor): add sticky offset control - #79879

Open
faisalahammad wants to merge 1 commit into
WordPress:trunkfrom
faisalahammad:fix/79732-sticky-offset
Open

faisalahammad wants to merge 1 commit into
WordPress:trunkfrom
faisalahammad:fix/79732-sticky-offset

Conversation

@faisalahammad

Copy link
Copy Markdown
Contributor

What?

Closes #79732

Adds a Sticky offset control to the Position panel, shown when a block's position is set to Sticky. Lets users set top/right/bottom/left offset values instead of the fixed 0px.

Why?

Blocks with Sticky position had no way to configure their offset from the viewport without custom CSS. The style.position.{top,right,bottom,left} attribute path already flowed through to CSS (editor) and PHP render, but no UI existed to set anything but 0px.

How?

Added a BoxControl (same component used for spacing/padding) inside PositionPanelPure in packages/block-editor/src/hooks/position.js, shown only when position is Sticky. Writes to the existing style.position attribute keys, so no CSS or PHP renderer changes were needed.

Testing Instructions

  1. Add a Group block (or any block supporting position).
  2. In the block inspector (Styles tab > Position), set Position to "Sticky".
  3. The new "Sticky offset" control appears below the position dropdown.
  4. Set values for top/right/bottom/left.
  5. Save and view the post; confirm the CSS reflects the offsets on the .wp-container-* class.
  6. Confirm resetting the Position panel clears the offset values.
  7. Confirm the control does not appear for Fixed position.

Testing Instructions for Keyboard

Tab to the Position panel, use arrow keys / typing to set offset values in the BoxControl inputs; all fields reachable and operable via keyboard.

Screenshots or screencast

Before After
No offset control Sticky offset BoxControl visible

Use of AI Tools

This PR was developed with the assistance of Claude Code (Anthropic). AI was used to help draft the implementation, which was reviewed before submission.

Adds BoxControl in PositionPanelPure when position is sticky. Reuses existing style.position path (already supported by CSS and PHP renderer).

Fixes WordPress#79732
@github-actions

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: faisalahammad <faisalahammad@git.wordpress.org>
Co-authored-by: TheRadicalDreamer <avagp@git.wordpress.org>
Co-authored-by: rohitmathur-7 <rohitmathur7@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions github-actions Bot added the [Package] Block editor /packages/block-editor label Jul 5, 2026
@github-actions

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown

Warning: Type of PR label mismatch

To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.

  • Required label: Any label starting with [Type].
  • Labels found: [Package] Block editor.

Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task.

@github-actions github-actions Bot added the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label Jul 5, 2026
@github-actions

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown

👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @faisalahammad! In case you missed it, we'd love to have you join us in our Slack community.

If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information.

This branch has not been deployed

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

Labels

First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository [Package] Block editor /packages/block-editor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a sticky offset control for blocks with Sticky position

1 participant