Make Block Inserter search input sticky while scrolling#77698
Make Block Inserter search input sticky while scrolling#77698sarthaknagoshe2002 wants to merge 2 commits intoWordPress:trunkfrom
Conversation
|
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 If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
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:
That would be consistent with |
|
Thanks for the feedback @jameskoster! |
| const handleScroll = useCallback( ( event ) => { | ||
| const hasScrolled = event.target.scrollTop > 0; | ||
| setIsScrolled( ( prevIsScrolled ) => { | ||
| if ( hasScrolled !== prevIsScrolled ) { | ||
| return hasScrolled; | ||
| } | ||
| return prevIsScrolled; | ||
| } ); | ||
| }, [] ); |
There was a problem hiding this comment.
| 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; |
There was a problem hiding this comment.
I believe this transition format is invalid.


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__searchSCSS to useposition: stickyandtop: 0. Added az-indexto 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
Screenshots or screencast