When focus returns to search box, auto highlight all text

(Wes Osborn) #1

If you perform a search and then click on the search icon or use the keyboard shortcut, the cursor will be placed at the end of the previous search term. To search for a new term, you must highlight the existing text via mousing, Crtl-A or Shift Arrows keys and then start typing.

The majority of the time I’m using searching, I’m attempting to search for something completely different than what I searched for earlier. If I want to refine, I enter the search results page and then refine the existing term from there.

In Google’s inbox, when focus is returned to search box, the entire existing term is auto highlighted:

That allows you to start typing immediately if you have a new term to search for, or hit the right arrow key if you need to refine an existing term. As a heavy searcher, I prefer the auto-highlight method and think Discourse should consider adopting it.

(Jeff Atwood) #2

Sure this might be easy can you take a look next week @sam?

(Alan Tan) #3

I implemented this while fixing some things with full page search.


(Sam Saffron) #4

Careful I support autofocus if the search term is blank, if it is not blank focusing will lose search position in the page on back which is real bad

(Alan Tan) #5

Could I clarify what “lose search position in the page” means? :sweat_smile:

(Sam Saffron) #6

I search for “testing”… scroll down 15 items, check one out, then hit back.

My expectation is that I return to the position I left, just like I do when using Google, not that I would be scrolled to the top with the word “testing” highlighted.

(Alan Tan) #7

Ah ok. :+1: I’ll make the changes :smile:

(Alan Tan) #8

I tested it out and the autofocus attribute doesn’t trigger on history back. However, it seems like the position on the page is preserved on Chrome but not on FireFox even without the autofocus attribute.

(Sam Saffron) #9

Focus on safari touch will certainly cause scroll, would prefer to just avoid it for back navigation

(Alan Tan) #10

Ic. In that case, I’ll just remove the autofocus :smile:

(Jeff Atwood) #11

Focus should fire on first search load ONLY. Because on mobile you obviously want to type something in to search FOR, yes?

(Kane York) #12

Remember to use ?mobile_view=1 to get mobile during testing.

(Alan Tan) #13

@wesochuck Patch has landed on master :smile: I really like the suggestion :+1:

(Alan Tan) #14

Lets close this :smile: :bear:

(Régis Hanol) #15

(Sam Saffron) #16

(Sam Saffron) #17

No… I do not support this… I just figured out what happens and it feels really weird.

If Google the mega search giant is not issuing a “select” on text in the box on focus… well there is a reason we should. I do not support “highlighting” all text on focus, that is just weird, if you want to do that it will have to be a plugin.

Google does not do this for Google.com
Ebay does not do this
Amazon does not do this
Microsoft does not do this
Apple do not do this, though they do this this strange thing

It’s a quirk of Google inbox, I don’t want us adopting this until it is prevalent, must be an extension.

(Alan Tan) #18

Depends on how true “my next search is going to be totally different terms” is. Even on google, I often find myself selecting all then backspace to enter a new search term.

This behaviour is actually present in the address bar of browsers though one may argue that the probability of entering something new in the address bar is alot higher than a search input. :panda_face:

(Sam Saffron) #19

Yeah for browser address bars you have almost 100% confidence that its a brand new thing the user is going to type. So yeah it makes sense.

But as an end user I find it very surprising to see these magic auto select fields. I think facebook which seems to have set the trend gets away with it cause it displays so much when you click anyway:

(Alan Tan) #20

I would argue that the behavior on Amazon and Google is different from what we have here. It doesn’t make sense for them to highlight the entire input because they are suggesting more terms based on the user’s input.

On Discourse, it sort of becomes a “trial and error” of keywords if I’m not exactly sure what I’m searching for. My search terms are often not an extension of the existing terms but totally new terms. :badpokerface: