Skip to content

fix: hide mobile search field on blur#2852

Open
alexdln wants to merge 2 commits into
npmx-dev:mainfrom
alexdln:fix/header-search-mobile
Open

fix: hide mobile search field on blur#2852
alexdln wants to merge 2 commits into
npmx-dev:mainfrom
alexdln:fix/header-search-mobile

Conversation

@alexdln
Copy link
Copy Markdown
Member

@alexdln alexdln commented Jun 4, 2026

🔗 Linked issue

Resolves #1881, Closes #2021

🧭 Context

Hiding the search field in the header on mobile devices when blurred (unfocused). We had logic for this, but the field component itself didn't support it, so I simply added correct events emit

Also adjusted the button sizes a bit so that they are in a better proportion to each other

@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented Jun 4, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
npmx.dev Ready Ready Preview, Comment Jun 4, 2026 9:38pm
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
docs.npmx.dev Ignored Ignored Preview Jun 4, 2026 9:38pm
npmx-lunaria Ignored Ignored Jun 4, 2026 9:38pm

Request Review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 4, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 33f389bc-00dc-4aee-b9b1-34d19e3a48bd

📥 Commits

Reviewing files that changed from the base of the PR and between 416555b and 4d8385f.

📒 Files selected for processing (1)
  • app/components/Header/SearchBox.vue
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/components/Header/SearchBox.vue

📝 Walkthrough

Summary by CodeRabbit

Release Notes

  • UI Updates
    • Adjusted mobile header button styling for improved visual consistency and touch comfort.
    • Improved search box focus and blur interactions for a smoother, more responsive user experience.

Walkthrough

Refactors mobile search focus/blur handling in SearchBox.vue (adds handleFocus/handleBlur, emits focus/blur, exposes blur) and updates mobile header ButtonBase class lists in AppHeader.vue to add a py-2.5! padding override for consistent vertical alignment.

Changes

Mobile search input handling and styling

Layer / File(s) Summary
SearchBox focus/blur handler refactoring
app/components/Header/SearchBox.vue
Introduces handleFocus and handleBlur functions that update isSearchFocused, call the input ref, and emit focus/blur. Adds a blur() wrapper and updates defineExpose to expose both focus and blur. Template @focus/@blur listeners now call the new handlers.
AppHeader mobile button styling
app/components/AppHeader.vue
Mobile search and menu icon ButtonBase elements have their class attributes adjusted to add py-2.5! padding overrides and remove prior spacing classes for consistent vertical alignment.
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix: hide mobile search field on blur' accurately describes the main change of adding blur event handling to dismiss the mobile search input.
Description check ✅ Passed The description clearly relates to the changeset, explaining the context of hiding the search field on blur and button size adjustments, whilst referencing the linked issues.
Linked Issues check ✅ Passed The PR addresses the core requirement from both issues (#1881, #2021) by implementing blur event handling to allow dismissal of the mobile search input through focus loss.
Out of Scope Changes check ✅ Passed All changes are directly related to the stated objectives: SearchBox.vue adds blur/focus event handling for search input dismissal, and AppHeader.vue adjusts button styling for better proportions.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 4, 2026

Codecov Report

❌ Patch coverage is 16.66667% with 5 lines in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
app/components/Header/SearchBox.vue 16.66% 5 Missing ⚠️

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
app/components/AppHeader.vue (1)

328-334: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Bind search button aria-expanded to search state, not menu state.

The mobile search trigger currently uses showMobileMenu, so assistive tech gets the wrong expanded/collapsed state for this control. Use isSearchExpanded here.

-        :aria-expanded="showMobileMenu"
+        :aria-expanded="isSearchExpanded"
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/components/AppHeader.vue` around lines 328 - 334, The ButtonBase mobile
search trigger binds aria-expanded to the wrong state; change the aria-expanded
binding from showMobileMenu to isSearchExpanded so assistive tech reflects the
search panel's state. Update the ButtonBase component instance (the element
using `@click`="expandMobileSearch" and v-if="!isSearchExpanded && !isOnHomePage")
to use :aria-expanded="isSearchExpanded" and ensure any related logic in
expandMobileSearch and the isSearchExpanded reactive/computed property remains
consistent.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@app/components/Header/SearchBox.vue`:
- Around line 33-43: The current handleFocus/handleBlur are used both as DOM
event handlers and as exposed imperative methods which causes duplicate emits
when calling searchBoxRef.value?.focus(); split responsibilities: keep the DOM
handlers (rename to onInputFocus/onInputBlur or similar) to set isSearchFocused
and emit('focus'/'blur'), and define separate exposed methods (focus and blur in
defineExpose) that only call inputRef.value?.focus()/blur() and set
isSearchFocused without calling emit; update defineExpose to expose those new
focus/blur methods and update any template/event binding to use the DOM handlers
(onInputFocus/onInputBlur).

---

Outside diff comments:
In `@app/components/AppHeader.vue`:
- Around line 328-334: The ButtonBase mobile search trigger binds aria-expanded
to the wrong state; change the aria-expanded binding from showMobileMenu to
isSearchExpanded so assistive tech reflects the search panel's state. Update the
ButtonBase component instance (the element using `@click`="expandMobileSearch" and
v-if="!isSearchExpanded && !isOnHomePage") to use
:aria-expanded="isSearchExpanded" and ensure any related logic in
expandMobileSearch and the isSearchExpanded reactive/computed property remains
consistent.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: c3d27dc2-88d8-434b-95b5-66b1eb951006

📥 Commits

Reviewing files that changed from the base of the PR and between 01c5100 and 416555b.

📒 Files selected for processing (2)
  • app/components/AppHeader.vue
  • app/components/Header/SearchBox.vue

Comment thread app/components/Header/SearchBox.vue Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Close mobile search input on click outside

1 participant