Skip to content

Search block: opinionated mobile behavior for button-only - #82185

Open
kmanijak wants to merge 1 commit into
trunkfrom
search-mobile-overlay
Open

kmanijak wants to merge 1 commit into
trunkfrom
search-mobile-overlay

Conversation

@kmanijak

@kmanijak kmanijak commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

What?

Give button-only Search an opinionated mobile overlay (≤600px):

  • no animation
  • cover nearby content without shifting layout

Desktop behavior stays unchanged.

How?

Keep the original button in flow and show a copied submit button inside an absolutely positioned full width overlay.

Why?

When button-only search is used among other elements, it squeezes and pushes out surrounding elements. When expanded, it leads to broken, unnatural layout.

Example use case is when used in header which I consider pretty common placement for search. In this case my page name is squeezed, content on the right is pushed out of the view and search itself exceeds the screen width.

Screen.Capture.on.2026-09-03.at.10-30-33.mp4

Testing Instructions

  1. Place button-only Search beside other blocks in a constrained Row. Test icon/text buttons and custom widths.
  2. On mobile, expand it: no layout shift/overflow, and no tap-highlight flash. Scroll and resize to desktop/back.

Keyboard

Tab to Search → Enter opens and focuses the input → Tab reaches submit. Check submission, Escape closes and restores focus, and tabbing outside closes without stealing focus. Resize while submit is focused.

Build, lint, PHP checks, and local Chrome checks passed. Automated regression tests and native-mobile coverage remain pending. Background images/gradients and translucent-background compositing are not handled.

Videos

Before After
Screen.Capture.on.2026-08-28.at.17-12-10.mp4
Screen.Capture.on.2026-08-28.at.17-09-04.mp4

Use of AI Tools

OpenAI Codex assisted with implementation, local checks, and this description under the author's direction and review.

Summary by CodeRabbit

  • Bug Fixes
    • Improved mobile Search block behavior in button-only mode.
    • Search expansion now overlays surrounding content without shifting the page layout.
    • Enhanced focus handling when opening, closing, resizing, or changing responsive layouts.
    • Added responsive styling and positioning for the mobile search overlay.
    • Improved accessibility labeling for mobile search controls.

@github-actions github-actions Bot added the [Package] Block library /packages/block-library label Aug 28, 2026
@kmanijak kmanijak changed the title Search: expand button-only search as a mobile overlay Search block: opinionated mobile behavior for button-only Aug 28, 2026
@carolinan

carolinan commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

Hi
I don't think it is clear enough what the why's are referring to, since this could mean different thing. Here a couple of screenshots would really help. is there an issue created for this and has it had a design feedback?

@carolinan carolinan added the [Block] Search Affects the Search Block - used to display a search field label Aug 30, 2026
@github-actions

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 library, [Block] Search.

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.

@kmanijak
kmanijak force-pushed the search-mobile-overlay branch from c59b625 to 1bf2259 Compare September 3, 2026 13:26
@coderabbitai

coderabbitai Bot commented Sep 3, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Team

Run ID: f7ffb4a6-f783-4288-af36-700bfd921b64

📥 Commits

Reviewing files that changed from the base of the PR and between 4f24138 and d96d4fa.

📒 Files selected for processing (4)
  • packages/block-library/CHANGELOG.md
  • packages/block-library/src/search/index.php
  • packages/block-library/src/search/style.scss
  • packages/block-library/src/search/view.js

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

The Search block now renders a responsive mobile overlay for button-only searches. It adds mobile-specific styling, overlay positioning, resize handling, and focus management.

Changes

Mobile Search overlay

Layer / File(s) Summary
Search overlay markup and accessibility
packages/block-library/src/search/index.php, packages/block-library/CHANGELOG.md
The renderer creates a separate mobile submit button, wraps expandable fields in an overlay, reuses ARIA labels, registers resize handling, and documents the fix.
Responsive overlay styling
packages/block-library/src/search/style.scss
Button-only searches use an absolute two-column mobile overlay below the small breakpoint. The original button retains its layout footprint while the mobile controls become visible.
Overlay positioning and focus handling
packages/block-library/src/search/view.js
Opening and resizing update overlay geometry and background state. Escape and focus-out handling preserve or restore focus across responsive visibility changes.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to d96d4

Button-only Search blocks gain a mobile overlay that expands without shifting surrounding layout while desktop behavior remains unchanged. No concrete current-head merge risk remains.

Sequence Diagram(s)

sequenceDiagram
  participant SearchBlockRenderer
  participant SearchView
  participant MobileOverlay
  SearchBlockRenderer->>MobileOverlay: render mobile fields and submit control
  SearchView->>MobileOverlay: update position and background when opening
  SearchView->>MobileOverlay: recalculate position on resize
  SearchView->>SearchBlockRenderer: restore focus after closing
Loading

Suggested reviewers: youknowriad

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the Search block and its button-only mobile behavior, which matches the main change. The term "opinionated" is somewhat broad but does not make the title misleading.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. (2 skipped: 2 …
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. (2 skipped: 2 unsupported.)

✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch search-mobile-overlay

Comment @coderabbitai help to get the list of available commands.

@kmanijak

kmanijak commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

I don't think it is clear enough what the why's are referring to, since this could mean different thing. Here a couple of screenshots would really help.

Sure, added example video to show what I mean.

is there an issue created for this and has it had a design feedback?

I don't think there is an issue and there was no design feedback. I created a draft PR to show the problem and an option to fix it but it doesn't mean it has to be the solution. I'm open to other ideas!

@kmanijak
kmanijak marked this pull request as ready for review September 3, 2026 14:01
@github-actions

github-actions Bot commented Sep 3, 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: kmanijak <karolmanijak@git.wordpress.org>
Co-authored-by: carolinan <poena@git.wordpress.org>
Co-authored-by: scruffian <scruffian@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 commented Sep 3, 2026 •

Copy link
Copy Markdown

🤖 PR meta 🤖

🏷️ Labels

This pull request needs exactly one label indicating its type, and has 0.

  • Required: any label starting with [Type].
  • Found: none.

Read more about Type labels in Gutenberg. If you cannot add labels yourself, a reviewer can do it for you.

📦 Bundle size

Size Change: +2.26 kB (+0.03%)

Total Size: 8.01 MB

📦 View Changed
Filename Size Change
build/modules/block-library/search/view.min.js 869 B +371 B (+74.5%) 🆘
build/styles/block-library/search/style-rtl.css 1.4 kB +298 B (+27.02%) 🚨
build/styles/block-library/search/style-rtl.min.css 918 B +250 B (+37.43%) 🚨
build/styles/block-library/search/style.css 1.4 kB +297 B (+26.88%) 🚨
build/styles/block-library/search/style.min.css 918 B +250 B (+37.43%) 🚨
build/styles/block-library/style-rtl.css 22.8 kB +222 B (+0.98%)
build/styles/block-library/style-rtl.min.css 19.2 kB +178 B (+0.93%)
build/styles/block-library/style.css 22.9 kB +219 B (+0.97%)
build/styles/block-library/style.min.css 19.2 kB +179 B (+0.94%)

d96d4fa Run

⚡ Performance

Show the results

Client side metrics exclude the server response time.

front-end-block-theme

Metric 25ff089 trunk % Change
timeToFirstByte 50.75 ms +5.32% -11.43% 52.35 ms +6.88% -14.33% -3.06%
largestContentfulPaint 78 ms +2.56% -10.26% 80 ms +10% -10% -2.5%
lcpMinusTtfb 26.45 ms +6.43% -7.75% 29.25 ms +16.92% -13.33% -9.57%
wpBeforeTemplate 25.76 ms +7.1% -16.27% 27.1 ms +10.37% -20.22% -4.94%
wpTemplate 20.32 ms +5.27% -4.43% 20.55 ms +5.26% -3.26% -1.12%
wpTotal 47.02 ms +4.51% -11.19% 47.7 ms +7.97% -12.96% -1.43%
wpMemoryUsage 7.54 MB +0% -0% 7.50 MB +0% -0% 0.46%
wpDbQueries 17 +0% -0% 17 +0% -0% 0%

front-end-classic-theme

Metric 25ff089 trunk % Change
timeToFirstByte 37.9 ms +6.99% -2.51% 38.3 ms +6.14% -2.61% -1.04%
largestContentfulPaint 76 ms +5.26% -5.26% 76 ms +5.26% -2.63% 0%
lcpMinusTtfb 37.15 ms +3.77% -5.38% 36.1 ms +5.68% -2.77% 2.91%
wpBeforeTemplate 19.24 ms +2.75% -0.99% 19.44 ms +15.69% -2.37% -1.03%
wpTemplate 15.37 ms +5.66% -1.11% 15.61 ms +4.48% -3.2% -1.54%
wpTotal 35.19 ms +7.25% -1.96% 35.59 ms +6.21% -3.01% -1.12%
wpMemoryUsage 6.17 MB +0% -0% 6.12 MB +0% -0% 0.74%
wpDbQueries 14 +0% -0% 14 +0% -0% 0%

media-processing

Metric 25ff089 trunk % Change
mediaProcessingJpeg 319.63 ms +1.01% -0.33% 323.8 ms +2.39% -0.94% -1.29%
mediaProcessingAvif 4957.24 ms +0.32% -0.13% 4939.42 ms +0.15% -0.12% 0.36%
mediaProcessingJpegToAvif 3536.82 ms +0.33% -0.17% 3532.46 ms +0.42% -0.09% 0.12%

media-upload

Metric 25ff089 trunk % Change
jpegUploadProcessing 1404.74 ms +1.9% -1.55% 1397.75 ms +1.57% -1.01% 0.5%
pngUploadProcessing 184.81 ms +4.37% -5% 185.5 ms +1.47% -5.11% -0.37%
largeJpegUploadProcessing 1397.28 ms +0.47% -1.41% 1394.75 ms +0.68% -0.52% 0.18%
multipleImageUploadProcessing 1469.19 ms +4.35% -1.52% 1480.4 ms +1.78% -1.17% -0.76%

post-editor

Metric 25ff089 trunk % Change
serverResponse 563.56 ms +4.71% -4.46% 550.92 ms +4.2% -6.45% 2.29%
firstPaint 234.27 ms +26.48% -10.99% 274.5 ms +16.88% -13.98% -14.66%
domContentLoaded 1315.72 ms +2.2% -2.79% 1319.8 ms +3.01% -0.74% -0.31%
loaded 1319.82 ms +1.99% -3% 1321.3 ms +3.01% -0.71% -0.11%
firstContentfulPaint 431.31 ms +2.43% -3.26% 441.57 ms +3.13% -2.49% -2.32%
firstBlock 3583.16 ms +1.76% -1.92% 3653.42 ms +0.72% -1.71% -1.92%
type 20.74 ms +12.83% -13.93% 21.44 ms +7.84% -15.86% -3.26%
typeWithoutInspector 20.76 ms +9.68% -7.08% 20.45 ms +14.82% -13.94% 1.52%
typeWithTopToolbar 23.61 ms +9.7% -20.37% 25.61 ms +13.35% -16.56% -7.81%
typeContainer 9.72 ms +6.79% -8.74% 9.65 ms +8.19% -11.4% 0.73%
focus 77.05 ms +15.46% -5.02% 87.58 ms +7.48% -12.81% -12.02%
firstFocus 173.87 ms +0% -0% 190.1 ms +0% -0% -8.54%
selectAll 611.29 ms +5.31% -3.01% 608.54 ms +3.26% -1.21% 0.45%
listViewOpen 73.47 ms +10.51% -2.94% 72.37 ms +8.5% -10.71% 1.52%
inserterOpen 22.89 ms +14.72% -7.25% 22.94 ms +8.11% -8.33% -0.22%
inserterHover 3.47 ms +9.8% -13.83% 3.68 ms +16.58% -10.33% -5.71%
inserterSearch 8.92 ms +7.85% -6.28% 8.48 ms +6.13% -5.07% 5.19%
loadPatterns 632.39 ms +4.98% -2.8% 626.79 ms +3.9% -1.61% 0.89%
wpTotal 553.14 ms +4.58% -4.4% 541.04 ms +4.23% -6.51% 2.24%
wpMemoryUsage 13.13 MB +0% -0% 13.10 MB +0% -0% 0.22%
wpDbQueries 54 +0% -1.85% 54 +0% -1.85% 0%

site-editor

Metric 25ff089 trunk % Change
serverResponse 408.48 ms +5.91% -7.77% 446.23 ms +1.19% -3.07% -8.46%
firstPaint 240.89 ms +8.54% -12.66% 246.79 ms +8.57% -11.71% -2.39%
domContentLoaded 1363.11 ms +0.54% -1.08% 1390.74 ms +1.74% -0.53% -1.99%
loaded 1364.46 ms +0.54% -1.09% 1391.98 ms +1.74% -0.52% -1.98%
firstContentfulPaint 414.28 ms +4.34% -6.79% 442.2 ms +3.67% -4.03% -6.31%
firstBlock 4192.13 ms +1.02% -0.79% 4298.36 ms +2.76% -1.14% -2.47%
type 19.48 ms +11.45% -19.3% 20.9 ms +11.1% -12.06% -6.79%
navigate 98.42 ms +12.16% -2.47% 98.16 ms +7.97% -1.15% 0.26%
loadPatterns 1354.06 ms +10.03% -9.09% 1408.93 ms +9.32% -13.49% -3.89%
loadPages 1122.9 ms +7.18% -3.8% 1128.23 ms +3.18% -2.79% -0.47%
wpTotal 397.87 ms +6.04% -7.92% 435.54 ms +1.13% -3.24% -8.65%
wpMemoryUsage 12.09 MB +0% -0% 12.05 MB +0% -0% 0.3%
wpDbQueries 43 +2.33% -0% 43 +2.33% -0% 0%

d96d4fa Run

@kmanijak kmanijak added [Package] Blocks /packages/blocks and removed [Package] Blocks /packages/blocks labels Sep 3, 2026
@kmanijak
kmanijak force-pushed the search-mobile-overlay branch from 1bf2259 to d96d4fa Compare September 3, 2026 14:03
@scruffian scruffian added the Needs Design Feedback Needs general design feedback. label Sep 7, 2026
@scruffian

Copy link
Copy Markdown
Contributor

A few thoughts:

  1. Rather than this change happening at 600px, could we use container queries to determine whether to use the overlay?
  2. I think focussing outside the search box should close it. Once the content gets covered it's not clear how to get it back (escape works but no everyone would know that).
  3. Is it also worth thinking about making the overlay more distinct from the content - for example, adding a background color/positioning it in the centre of the canvas? Personally I think not, but I wondered if others had a different perspective.

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

[Block] Search Affects the Search Block - used to display a search field Needs Design Feedback Needs general design feedback. [Package] Block library /packages/block-library

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants