Skip to content

Make Block Inserter search input sticky while scrolling#77698

Open
sarthaknagoshe2002 wants to merge 2 commits intoWordPress:trunkfrom
sarthaknagoshe2002:fix/issue-71995
Open

Make Block Inserter search input sticky while scrolling#77698
sarthaknagoshe2002 wants to merge 2 commits intoWordPress:trunkfrom
sarthaknagoshe2002:fix/issue-71995

Conversation

@sarthaknagoshe2002
Copy link
Copy Markdown
Contributor

What?

Closes #71995

Makes the search input inside the block inserter panel sticky so it remains visible while scrolling through blocks.

Why?

Currently, the search bar scrolls out of view when browsing long lists of blocks. This change prevents users from having to unnecessarily scroll back to the top just to access the search functionality, improving overall workflow and usability.

How?

Updated the .block-editor-inserter__search SCSS to use position: sticky and top: 0. Added a z-index to ensure the scrolled blocks slide cleanly underneath the search input. Intentionally omitted the background color to allow the blocks to remain visible as they slide past the search area, creating a nice visual effect.

Testing Instructions

  1. Open a post or page in the editor.
  2. Click the + (Toggle block inserter) button in the top-left toolbar to open the inserter panel.
  3. Scroll down through the list of available blocks.
  4. Verify that the search input remains fixed at the top of the panel and that blocks scroll cleanly underneath it.

Screenshots or screencast

Before After
image image

@github-actions github-actions Bot added the [Package] Block editor /packages/block-editor label Apr 27, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 27, 2026

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: sarthaknagoshe2002 <sarthaknagoshe2002@git.wordpress.org>
Co-authored-by: jameskoster <jameskoster@git.wordpress.org>
Co-authored-by: vincent-bdrt <vincentbdrt@git.wordpress.org>

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

@t-hamano t-hamano added [Type] Enhancement A suggestion for improvement. [Feature] Inserter The main way to insert blocks using the + button in the editing interface Needs Design Feedback Needs general design feedback. labels Apr 28, 2026
@t-hamano t-hamano requested a review from a team April 28, 2026 08:07
@jameskoster
Copy link
Copy Markdown
Contributor

This seems reasonable to me. The visual effect of the field colliding with the rest of the UI looks a bit off though. Perhaps the search container should have a background, and reveal a border on scroll:

Screenshot 2026-04-28 at 13 19 33

That would be consistent with Dialog.

@sarthaknagoshe2002
Copy link
Copy Markdown
Contributor Author

Thanks for the feedback @jameskoster!
I've just pushed an update to align this with the Dialog's behavior:

Copy link
Copy Markdown
Contributor

@t-hamano t-hamano left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!

At the very least, we need to fix the following two problems.

First, onScrollCapture can also react to the scrolling of child elements, which may cause isScrolled to change incorrectly.

on-scroll-capture.mp4

Second, the padding is missing in the Media tab.

Image

Comment on lines +173 to +181
const handleScroll = useCallback( ( event ) => {
const hasScrolled = event.target.scrollTop > 0;
setIsScrolled( ( prevIsScrolled ) => {
if ( hasScrolled !== prevIsScrolled ) {
return hasScrolled;
}
return prevIsScrolled;
} );
}, [] );
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
const handleScroll = useCallback( ( event ) => {
const hasScrolled = event.target.scrollTop > 0;
setIsScrolled( ( prevIsScrolled ) => {
if ( hasScrolled !== prevIsScrolled ) {
return hasScrolled;
}
return prevIsScrolled;
} );
}, [] );
const handleScroll = useCallback( ( event ) => {
setIsScrolled( event.target.scrollTop > 0 );
}, [] );

This can be simplified.

z-index: 2;
background-color: $white;
border-bottom: 1px solid transparent;
transition: border-bottom-color 0 linear;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I believe this transition format is invalid.

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 Needs Design Feedback Needs general design feedback. [Package] Block editor /packages/block-editor [Type] Enhancement A suggestion for improvement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Proposal: Make the search input in the Block Inserter sticky

3 participants