maps icon indicating copy to clipboard operation
maps copied to clipboard

Fix mobile search bar keyboard issue on Android browsers

Open Copilot opened this issue 3 months ago • 0 comments

The search bar on mobile browsers (Chrome/Firefox on Android) was not showing the soft keyboard when tapped, preventing users from entering search terms. This only affected mobile browsers - the desktop site worked correctly.

Root Cause

The NcSelect component's input element was missing mobile-specific attributes and proper touch event handling needed to trigger the virtual keyboard on mobile devices.

Solution

Added minimal changes to SearchField.vue to enhance mobile compatibility:

1. Mobile-specific input attributes

input.setAttribute('inputmode', 'search')      // tells mobile browsers this is a search input
input.setAttribute('enterkeyhint', 'search')   // shows "search" on the enter key
input.setAttribute('autocorrect', 'off')       // disables autocorrect for better search UX
input.setAttribute('autocapitalize', 'off')    // disables auto-capitalization

2. Enhanced touch event handling

container.addEventListener('touchstart', () => {
    setTimeout(() => {
        input.focus()
    }, 50)
}, { passive: true })

3. Improved focus() method with mobile detection

if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
    input.focus()
    input.click()  // Additional click trigger for mobile virtual keyboard
} else {
    input.focus()  // Desktop behavior unchanged
}

Testing

The fix has been verified to:

  • ✅ Apply correct mobile-specific attributes to input elements
  • ✅ Handle touch events properly on mobile devices
  • ✅ Preserve existing desktop functionality
  • ✅ Build without errors and pass linting

Test demonstration showing mobile-optimized search input with proper attributes

This addresses a regression since mobile keyboards previously worked, building on the mobile browser fixes from version 0.1.2 and mobile improvements in version 1.1.0.

Fixes #1337.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot avatar Sep 12 '25 08:09 Copilot