ubuntu.com icon indicating copy to clipboard operation
ubuntu.com copied to clipboard

Clearing search field annoyingly defocuses it

Open matthewpaulthomas opened this issue 4 years ago • 3 comments

  1. Focus the search field in the navigation bar.
  2. Type some text.
  3. Click the clear button.
  4. Start typing some different text.

What should happen: The text you type appears in the search field.

What actually happens: The text is lost, because the search field is no longer focused.

According to vanilla-framework#2866 this won’t be fixed in Vanilla, so it needs to be fixed for each search field individually. It may be possible to copy the code used to fix it in the vanillaframework.io/docs search field.


Reported from: https://ubuntu.com/

matthewpaulthomas avatar Mar 16 '20 08:03 matthewpaulthomas

@bartaz do you think this could be a vanilla issue?

petesfrench avatar Nov 16 '21 16:11 petesfrench

I can't replicate this. I have cleared the site search and the search pattern example and both refocus on the input after clearing.

anthonydillon avatar Nov 16 '21 18:11 anthonydillon

I guess on ubuntu.com this issue predates the new expanding search that you can't clear, because "clear" button closes it (which could be considered issue itself).

This particular one was JS issue. Native behaviour of reset button resets the whole form, to keep focus in search field JS needs to do it explicitly. In past it didn't. It is fixed in Vanilla examples, but likely was never updated in projects.

History lesson aside - this particular issue can be closed I think because expanding search in the navigation changes the behaviour and there is no reset button anymore.

bartaz avatar Nov 17 '21 06:11 bartaz

Search has changed now, this no longer seems to be an issue.

carkod avatar Aug 11 '23 10:08 carkod