Skip to content

fix(css): improve mobile responsiveness for navbar search and header#329

Open
shubhtrek wants to merge 1 commit into
kmesh-net:mainfrom
shubhtrek:fix/mobile-navbar-search-responsiveness
Open

fix(css): improve mobile responsiveness for navbar search and header#329
shubhtrek wants to merge 1 commit into
kmesh-net:mainfrom
shubhtrek:fix/mobile-navbar-search-responsiveness

Conversation

@shubhtrek

@shubhtrek shubhtrek commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Summary

Re-submission of #310 and Solves #304 (auto-closed when fork was accidentally deleted).

On screens narrower than 996px the search input was expanding to its full intrinsic
width, squeezing the logo and hamburger toggle out of view. Category labels inside
the lunr-search results modal would also wrap awkwardly or get truncated on
sub-400px viewports.

Changes in src/css/custom.css

  • Constrain .navbar__search to max-width: 160px on mobile so the logo and
    hamburger always have room (flex-shrink + min-width: 0).
  • Hide DocSearch placeholder text on mobile (icon-only saves space).
  • Lock .navbar__brand with flex-shrink: 0 to prevent logo clipping.
  • Below 400px: collapse search to icon-only width (2.2rem) when idle,
    expand to full width on focus using :focus-within.
  • Font size is NOT set to 0 — this prevents the iOS Safari auto-zoom bug
    (addressed from previous review feedback).
  • In the lunr-search results dropdown: apply text-overflow: ellipsis to
    category headings, clamp snippet text to 2 lines, tighten padding.
  • At 400px and below: stretch the results modal using left: 0 + right: 0
    (NOT width: 100vw) to avoid horizontal overflow from scrollbar width.
  • Added 60vh max-height with scroll so it never clips outside the viewport.

Review Feedback Addressed (from #310)

Issue Fix
font-size: 0 triggers iOS Safari zoom Removed — font size never touched
width: 100vw causes horizontal overflow Changed to left: 0 + right: 0
Search unusable when collapsed Added :focus-within to expand on tap

Closes #304

Signed-off-by: Shubh Pingale <135618936+shubhtrek@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 5, 2026 09:20
@netlify

netlify Bot commented Jul 5, 2026

Copy link
Copy Markdown

Deploy Preview for kmesh-net ready!

Name Link
🔨 Latest commit 49aa453
🔍 Latest deploy log https://app.netlify.com/projects/kmesh-net/deploys/6a4a21dcc8979f000849e11e
😎 Deploy Preview https://deploy-preview-329--kmesh-net.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@kmesh-bot

Copy link
Copy Markdown
Collaborator

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign lizhencheng9527 for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request introduces CSS changes to improve the responsiveness of the mobile navbar search and the Lunr search results modal on smaller viewports. The review feedback highlights two important layout improvements: constraining the expanded search bar width on focus to prevent layout breakage on narrow viewports, and explicitly defining the top and z-index properties for the fixed search results container to ensure consistent vertical positioning and correct layering.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread src/css/custom.css
Comment on lines +205 to +207
.navbar__search:focus-within {
max-width: 100%;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

On extremely narrow viewports (under 400px), setting max-width: 100% on focus can cause the search bar to push other elements (like the logo or hamburger menu) completely out of the viewport or trigger horizontal overflow. Since .navbar__brand has flex-shrink: 0 to prevent logo clipping, the combined width of the brand, the expanded search bar, and the hamburger toggle will exceed the viewport width.

To prevent this layout breakage, constrain the expanded width of the search bar to the remaining available space using a dynamic calc() function.

Suggested change
.navbar__search:focus-within {
max-width: 100%;
}
.navbar__search:focus-within {
max-width: calc(100vw - 150px);
}

Comment thread src/css/custom.css
Comment on lines +251 to +261
[class*="searchResultsContainer"],
.lunr-search-results,
#lunr-search-results-container {
position: fixed;
left: 0;
right: 0;
max-height: 60vh;
overflow-y: auto;
border-radius: 0;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

When using position: fixed on the search results container, omitting the top property can lead to highly inconsistent vertical positioning across different mobile browsers (especially on iOS Safari when the virtual keyboard is active). The browser will fall back to the element's "static position", which can cause the results modal to overlap the search input itself or render off-screen.

Additionally, without an explicit z-index, the modal might render behind other fixed or sticky elements on the page (such as the mobile sidebar, back-to-top button, or table of contents).

To ensure consistent rendering and visibility, explicitly define top (using Docusaurus's navbar height variable --ifm-navbar-height) and a safe z-index.

  [class*="searchResultsContainer"],
  .lunr-search-results,
  #lunr-search-results-container {
    position: fixed;
    top: var(--ifm-navbar-height, 3.75rem);
    left: 0;
    right: 0;
    max-height: 60vh;
    overflow-y: auto;
    border-radius: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: var(--ifm-z-index-dropdown, 100);
  }

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR adjusts site CSS to improve mobile responsiveness of the navbar search area and the Lunr search results UI, primarily targeting cramped layouts on <996px and <400px viewports (issue #304).

Changes:

  • Adds mobile breakpoints to constrain/collapse the navbar search area and preserve space for the logo + hamburger.
  • Tweaks Lunr search result presentation on small screens (ellipsis for headings, clamped snippets, tighter padding).
  • Makes the results container full-width on very small screens via left: 0 / right: 0 and adds a viewport-based max-height + scrolling.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/css/custom.css
Comment on lines +184 to +188
/* Hide the placeholder text — icon-only saves horizontal space */
.navbar__search input::placeholder,
.DocSearch-Button-Placeholder {
display: none;
}
Comment thread src/css/custom.css
Comment on lines +220 to +227
/* Truncate long category headings with ellipsis */
.search-result-match__category,
[class*="searchResultItem"] h3,
[class*="lunr"] .category-label {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[UI/UX] Improve Mobile Responsiveness for Search and Navbar

3 participants