flathub-infra / linux-store-frontend

A web application to browse and install applications present in Flatpak repositories. Powers https://www.flathub.org
Apache License 2.0
187 stars 50 forks source link

clicking the magnifying glass doesn't focus the search input field #320

Open skierpage opened 2 years ago

skierpage commented 2 years ago

Open flathub.org in Firefox or chromium-browser, and click the magnifying glass icon in the header. A text field appears with "Search apps" placeholder text, but this does not have the input focus. You have to click a second time to type anything into it, or press [Shift+Tab] to move the focus to it A minor detail, but it feels weird.

Looking at the HTML for the search box,

<input _ngcontent-bgw-c94="" id="search-box" type="search" placeholder="Search apps"
   autofocus="" autocapitalize="none" class="search-box">

you would think the autofocus="" would put the input focus there.

In fact, if you bring up a flathub page and immediately type BAZINGA, then click the magnifying glass, the search box appears with your typed text in it. So the initial input focus is set to this invisible field (you can [Tab] and [Shift+Tab] from it to the magnifying glass and 3-dot menu), but when you click on the magnifying glass, your keyboard focus doesn't return to the search box. After clicking the magnifying glass, typing document.activeElement in the browser developer tools console displays <button _ngcontent-bgw-c94="" mat-icon-button="" class="mat-focus-indicator ...">, not the input#search-box.search-box. If you tab backwards and forwards you can see the input focus ring highlight "behind" the search box where the magnifying glass was visible.

hotlittlewhitedog commented 2 years ago

https://github.com/flathub/linux-store-frontend/issues/225