Page MenuHomePhabricator

InputBox on mobile skin (Minerva) loses focus on first click, jumping to main search bar
Open, LowPublicBUG REPORT

Description

Steps to replicate the issue (include links if applicable):
Open a page which uses inputbox with the minerva skin. I created a minimal example under https://en.wikipedia.org/wiki/User:Kallichore/sandbox2?useskin=minerva

What happens?:
On the first click inside the inputbox the page's focus immediately jumps to the main search bar. The inputbox works correctly on the second and subsequent clicks.

What should have happened instead?:
There should be no jump, the text cursor should appear inside the infoxbox.

Software version (on Special:Version page; skip for WMF-hosted wikis like Wikipedia):
I observed this both in de.Wikipedia and en.Wikipedia.

Other information (browser name/version, screenshots, etc.):
The problem was first reported here on the German Wikipedia: https://de.wikipedia.org/w/index.php?title=Wikipedia%3AFragen_zur_Wikipedia&diff=258901835&oldid=258900633

Event Timeline

Jdlrobson-WMF subscribed.

Can replicate.

This requires a change in Minerva to resources/skins.minerva.search/searchTypeahead.js file:
Currently we have autofocusInput: true, but this should instead check if document.activeElement matches the element being hydrated to a Vue component.

As an even better more complete solution, this file should consider the fact there might be multiple search elements on the page and enhance them all.

Change #1206961 had a related patch set uploaded (by TheDJ; author: TheDJ):

[mediawiki/skins/MinervaNeue@master] Search: Only focus search if it is the active element

https://gerrit.wikimedia.org/r/1206961

Change #1206961 merged by jenkins-bot:

[mediawiki/skins/MinervaNeue@master] Search: Only focus search if it is the active element

https://gerrit.wikimedia.org/r/1206961

TheDJ claimed this task.

I tested the example under https://en.wikipedia.org/wiki/User:Kallichore/sandbox2?useskin=minerva on en.Wikipedia with MW 1.46.0-wmf.4:

  • no loss of focus under Firefox 140.5.0esr on my desktop computer (issue resolved)
  • loss of focus on my Android phone (I tested Samsung Internet, Chrome and Firefox) (issue not resolved on mobile)

Right.. this is ok, it's just doing it for BOTH searchinputs now, and one of them will always have focus of course...

This is because minerva assumes that the input it is finding goes with the form that it wants to infuse...

The TypeaheadSearchWrapper of core is mounted in opened state for minerva, whereas in vector it is display:non'ed...

[edit] wrong trail

[edit]: There is another bug btw, that when you close this dialog, then reclick the search button, the focus on the input doesn't work (it was moved, and isn't being reset, as there doesn't seem to be an actual 'open' event ??).

[edit]: It seems that useMobileExperience.value is used as the STATE of the window. So this value should take into account autofocusInput on the initial usage.

[edit] Ugh. someone really needs to invest time into this and separate out FOCUS from OPEN events/states (can't believe this ended on production).

Change #1213989 had a related patch set uploaded (by TheDJ; author: TheDJ):

[mediawiki/core@master] typeahead debugging..

https://gerrit.wikimedia.org/r/1213989

k. so i verified that by NOT assuming that the component should always be opened on mobile (see the WIP) I fix the problem, but this reintroduces the problem of inputbox opening up the window (global state?)

I also checked if i could fix it by telling minerva to check for focus on the searchIcon, but the searchIcon triggers something in core to setup routes, which creates a dangling input, which steals the focus, which the minerva side cannot know about when and how that happens exactly and the mounted state uses global context etc etc. etc. it's one big hole of assumptions that are not always valid.

This integration needs serious rework to separate 'being injected and mounted' from 'being open and active' from 'a specific search element that we support wants the component to be active'.