# When focus returns to search box, auto highlight all text

**URL:** https://meta.discourse.org/t/when-focus-returns-to-search-box-auto-highlight-all-text/33125
**Category:** UX
**Created:** [11 Septiembre, 2015 14:41 UTC](https://meta.discourse.org/t/when-focus-returns-to-search-box-auto-highlight-all-text/33125 "2015-09-11T14:41:33Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![wesochuck](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/wesochuck/32/108706_2.png) [@wesochuck](https://meta.discourse.org/u/wesochuck)
#### Post date: [11 Septiembre, 2015 14:41 UTC](https://meta.discourse.org/t/when-focus-returns-to-search-box-auto-highlight-all-text/33125/1 "2015-09-11T14:41:33Z")

</div>

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:

 ![](https://global.discourse-cdn.com/meta/original/3X/0/4/046379ff4346d9c68721c24b74934fd6119b2434.png)

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.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [11 Septiembre, 2015 21:12 UTC](https://meta.discourse.org/t/when-focus-returns-to-search-box-auto-highlight-all-text/33125/2 "2015-09-11T21:12:47Z")

</div>

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

---

<div class="post-metadata">

### Author: ![tgxworld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tgxworld/32/106117_2.png) [@tgxworld](https://meta.discourse.org/u/tgxworld)
#### Post date: [12 Septiembre, 2015 06:37 UTC](https://meta.discourse.org/t/when-focus-returns-to-search-box-auto-highlight-all-text/33125/3 "2015-09-12T06:37:02Z")

</div>

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

[https://github.com/discourse/discourse/pull/3757/commits](https://github.com/discourse/discourse/pull/3757/commits)

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [12 Septiembre, 2015 06:39 UTC](https://meta.discourse.org/t/when-focus-returns-to-search-box-auto-highlight-all-text/33125/4 "2015-09-12T06:39:31Z")

</div>

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

---

<div class="post-metadata">

### Author: ![tgxworld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tgxworld/32/106117_2.png) [@tgxworld](https://meta.discourse.org/u/tgxworld)
#### Post date: [12 Septiembre, 2015 06:57 UTC](https://meta.discourse.org/t/when-focus-returns-to-search-box-auto-highlight-all-text/33125/5 "2015-09-12T06:57:48Z")

</div>

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

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [12 Septiembre, 2015 07:18 UTC](https://meta.discourse.org/t/when-focus-returns-to-search-box-auto-highlight-all-text/33125/6 "2015-09-12T07:18:56Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![tgxworld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tgxworld/32/106117_2.png) [@tgxworld](https://meta.discourse.org/u/tgxworld)
#### Post date: [12 Septiembre, 2015 07:51 UTC](https://meta.discourse.org/t/when-focus-returns-to-search-box-auto-highlight-all-text/33125/7 "2015-09-12T07:51:29Z")

</div>

Ah ok. 👍 I’ll make the changes 😄

---

<div class="post-metadata">

### Author: ![tgxworld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tgxworld/32/106117_2.png) [@tgxworld](https://meta.discourse.org/u/tgxworld)
#### Post date: [12 Septiembre, 2015 09:22 UTC](https://meta.discourse.org/t/when-focus-returns-to-search-box-auto-highlight-all-text/33125/8 "2015-09-12T09:22:33Z")

</div>

![](https://global.discourse-cdn.com/meta/original/3X/f/0/f07714a5fbc6e1a6028d11aa5d73b90d416438a2.gif)

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.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [12 Septiembre, 2015 10:46 UTC](https://meta.discourse.org/t/when-focus-returns-to-search-box-auto-highlight-all-text/33125/9 "2015-09-12T10:46:43Z")

</div>

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

---

<div class="post-metadata">

### Author: ![tgxworld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tgxworld/32/106117_2.png) [@tgxworld](https://meta.discourse.org/u/tgxworld)
#### Post date: [12 Septiembre, 2015 11:06 UTC](https://meta.discourse.org/t/when-focus-returns-to-search-box-auto-highlight-all-text/33125/10 "2015-09-12T11:06:59Z")

</div>

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

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [12 Septiembre, 2015 11:13 UTC](https://meta.discourse.org/t/when-focus-returns-to-search-box-auto-highlight-all-text/33125/11 "2015-09-12T11:13:29Z")

</div>

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

---

<div class="post-metadata">

### Author: ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)
#### Post date: [12 Septiembre, 2015 16:34 UTC](https://meta.discourse.org/t/when-focus-returns-to-search-box-auto-highlight-all-text/33125/12 "2015-09-12T16:34:41Z")

</div>

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

---

<div class="post-metadata">

### Author: ![tgxworld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tgxworld/32/106117_2.png) [@tgxworld](https://meta.discourse.org/u/tgxworld)
#### Post date: [14 Septiembre, 2015 12:53 UTC](https://meta.discourse.org/t/when-focus-returns-to-search-box-auto-highlight-all-text/33125/13 "2015-09-14T12:53:03Z")

</div>

@wesochuck Patch has landed on master 😄 I really like the suggestion 👍

---

<div class="post-metadata">

### Author: ![tgxworld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tgxworld/32/106117_2.png) [@tgxworld](https://meta.discourse.org/u/tgxworld)
#### Post date: [15 Septiembre, 2015 08:56 UTC](https://meta.discourse.org/t/when-focus-returns-to-search-box-auto-highlight-all-text/33125/14 "2015-09-15T08:56:00Z")

</div>

Lets close this 😄 🐻

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [15 Septiembre, 2015 09:11 UTC](https://meta.discourse.org/t/when-focus-returns-to-search-box-auto-highlight-all-text/33125/15 "2015-09-15T09:11:37Z")

</div>



---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [16 Septiembre, 2015 04:38 UTC](https://meta.discourse.org/t/when-focus-returns-to-search-box-auto-highlight-all-text/33125/16 "2015-09-16T04:38:13Z")

</div>



---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [16 Septiembre, 2015 04:39 UTC](https://meta.discourse.org/t/when-focus-returns-to-search-box-auto-highlight-all-text/33125/17 "2015-09-16T04:39:56Z")

</div>

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](http://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

 ![](https://global.discourse-cdn.com/meta/original/3X/3/6/36128ada8cfae2e5ba0d30ec958c9fbd20ee5e5e.png)

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

---

<div class="post-metadata">

### Author: ![tgxworld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tgxworld/32/106117_2.png) [@tgxworld](https://meta.discourse.org/u/tgxworld)
#### Post date: [16 Septiembre, 2015 05:17 UTC](https://meta.discourse.org/t/when-focus-returns-to-search-box-auto-highlight-all-text/33125/18 "2015-09-16T05:17:25Z")

</div>

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. 🐼

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [16 Septiembre, 2015 05:31 UTC](https://meta.discourse.org/t/when-focus-returns-to-search-box-auto-highlight-all-text/33125/19 "2015-09-16T05:31:09Z")

</div>

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:

 ![](https://global.discourse-cdn.com/meta/original/3X/e/d/edf372f89d8861a2b83c6f7c70fc2f84a1db9f6b.png)

---

<div class="post-metadata">

### Author: ![tgxworld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tgxworld/32/106117_2.png) [@tgxworld](https://meta.discourse.org/u/tgxworld)
#### Post date: [16 Septiembre, 2015 05:55 UTC](https://meta.discourse.org/t/when-focus-returns-to-search-box-auto-highlight-all-text/33125/20 "2015-09-16T05:55:55Z")

</div>

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.

 ![](https://global.discourse-cdn.com/meta/original/3X/e/b/eb98e7252b56b2bc2bfe2652431e5390317afd43.png)

 ![](https://global.discourse-cdn.com/meta/original/3X/b/b/bb7d52e7015f2ff3cbecd6851f70a9a59ab55bb7.png)

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:

[Página siguiente](https://meta.discourse.org/t/when-focus-returns-to-search-box-auto-highlight-all-text/33125.md?page=2)
