Discourse taking over Ctrl-F


(Marcelo Delgado) #1

Ctrl-F is for searching the page, for example specific text in a conversation (huge use case). Discourse seems to think it knows better and wants to search other conversations for the text. Thus leaving one no way to search the actual page you’re on for text. Taking over and changing browser functionality is very bad.

This is happening on Chrome.


Options to disable hijack of CMD+F / CTRL+F and "/" keys for search?
Pressing Ctrl+F twice on topic search should close the Discourse search window
Search keyboard shortcuts hijacked?
(Sam Saffron) #2

@codinghorror maybe I should tweak it so we only kidnap on topics with more than 10 posts.


(Adnan Issadeen) #3

There was a thread where the final part of it ended on saying that they were disabling the ctrl f default behaviour. Not a bug but it is agreeably a debatable choice.


(Adnan Issadeen) #4

@sam any reason why you can’t switch it to ctrl shift f (or any other shortcut)? I’m curious. Why the ctrl f choice anyways? Most people I work with rarely use the ctrl f in the browser, and the ones that do are people that care about shortcuts for the most part. Those people would care about learning ctrl shift f as a shortcut to search and would appreciate you not kidnapping the default behaviour.


(Sam Saffron) #5

CTRL F is essentially broken on many counts on any topic with more than 10 posts or so.


(Adnan Issadeen) #6

It still just seems so weird to take over a main browser shortcut. Just a thought, although I’m not sure I like it myself due to bloat. Let ctrl f be your custom implementation to search the page since the browser can’t help but trip over itself. And let ctrl shift f be the sitewide search. Thoughts?


(Sam Saffron) #7

post cloaking, means that a pile of posts are removed from the dom, so you search stuff and its just not there.

on top of that replaceState (happens on scroll) causes chrome to clear its currently active search resulting in real buggy behavior.

I much prefer focusing on improving our search function than trying to limp the built in one into a working state.


(Jeff Atwood) #8

Same reason Google Docs captures Ctrl+F as well.

@phaedrus_one if you try to use in-page search on a Discourse topic with more than a trivial number of posts, you’ll find that most of the posts are not loaded in the browser. So on-page search isn’t going to do squat for you.

So I believe, very strongly, that this is a correct behavior.


(Kalvin Greis) #9

I don’t understand how to search the topic I’m in. Hitting ctrl-F brings up a search of topics, not a search of the topic I’m on.


(Kane York) #10

If you’re in a topic less than 10 posts, until automatic scroll-highlighting is done, and with a high enough slack ratio, you can hit ctrl-F twice for the default search.


(Neil Lalonde) #11

It does a search of the topic you’re in first, and then a search of topics. This is what I get in this topic:


(Kalvin Greis) #12

Ahh, I see now. I don’t understand the use-case for combining those two features under one control though. I either want to search the text of the topic I’m on, or I want to search the list of topics.


(Kris) #13

There’s been a fair amount of confusion around the posts/topics search results… maybe when the results are posts within a thread the results header shouldn’t say “topics”?


(Sam Saffron) #14

I made a bunch of tweaks today.

  1. CTRL-F is only kidnapped on Topic/Topic List/User Activity pages.
  2. Topic search will highlight the work you are searching for
  3. Topic search will work even with only 1 post
  4. Clicking between results within a topic will not hide the search dialog

Hopefully this makes this less painful


(Jeff Atwood) #15

It now says “results” instead of “topics”.


(Erlend Sogge Heggen) #16

For the record, I would really like to see the exact functionality of CTRL-F eventually (i.e. post-1.0) replicated and implemented as a “Jump to word” search option that’s defaulted to when search is accessed via CTRL-F, because:

  • CTRL-F is a very different type of search from a data-base search. For instance, @techAPJ recently made an edit to his tutorial saying he’d added a section about FooBar. I tried to CTRL-F for it, but all that gets me is his full 20 paragraph post.
  • Even though CTRL-F is a geek’s tool, the type of search is very useful and I sorely wish more people knew about it. Every time I show this little trick to one of my friends they go “What? What did you just do? You can do that!?”. Discourse could encourage it’s use by incorporating it into the search dialogue.

I’ll make a mockup when I’m not feeling lazy.


(Jeff Atwood) #17

It already works that way, click on the result. The target words are highlighted and will be moved into focus.


(Andrew Meyer) #18

Actually it looks like the results aren’t moved into focus, just the individual post. For longer posts that behavior is not nearly as useful as the browser’s behavior jumping to the actual word.

Trying to duplicate the browser’s functionality this way seems like a tricky task, given that some browsers implement search differently than others. For example in Chrome, if the first result isn’t what I’m looking for, I usually hit enter to go to the next result. Discourse’s search functionality doesn’t work that way.


(Nition) #20

I’d like to second this being an issue. The override seems OK for finding if something is in a thread, but not so good for finding where. A lot of forum visits come from search engine results where the visitor already knows the text they’re looking for because they saw it in the preview. If search words are meant to be highlighted and moved into focus, that would solve the problem, but at the moment that doesn’t seem to be happening (I’m using Chrome 36).

Example:
Imagine Jimmy wants to know how to pin a topic on a Discourse forum. He searches Google for pin topic discourse or whatever, and he sees a result with a text preview saying “…icon in the upper right to get the staff menu for the topic; select Pin Topic.”

That looks right, so he ends up here: Discourse Admin Quick Start Guide - phylobabble

That’s a big post, so he Ctrl-F searches for “pin topic”. Normally his browser would already be highlighting the text in the post, but nothing happens, so he tries clicking on the only result. This just refreshes the page and puts him back at the same post.

At this point Jimmy either leaves the forum to try another result that doesn’t hijack his browser search, combs the whole thread manually, or mashes Ctrf-F enough that he discovers the Ctrl-F-F override and types “pin topic” again, instantly highlighting the section that he wanted all along.


(Jeff Atwood) #21

We changed it so that ctrl+f triggers Discourse search only when there are more than 20 posts loaded in the current topic stream.

So on smaller topics, this now works like the browser default.

Only on larger topics will you get Discourse search, which is necessary because not all posts are loaded in the DOM (think 100+ replies) at any given time, only the visible ones are.