Options to disable hijack of CMD+F / CTRL+F and "/" keys for search?

That is now complete:

https://github.com/discourse/discourse/commit/8e31fe4835c7f7a2028703c7c92deb75c7b4102e

next up, decide if we want to keep CTRL-F on topic lists. I think we should drop that hijacking cause its really not offering full parity (no highlighting and so on)

3 Likes

You can technically ā€œescapeā€ the hijack by hitting CTRL+F twice
tested in chrome and firefox

but do be prepare for some bugs (tested on chrome) with native find capabilities
for example you canā€™t use Enter to go to the next match all the time because it triggered the ā€œquote replyā€
which closes the native search.

6 Likes

As an end-user, I gotta say that hijacking native browser search (Cmd+F) is unexpected behavior (aka a ā€œbugā€) from my perspective. I can click on the search icon and, if I hadnā€™t learned to use ā€œ/ā€ for searching within an application from Gmail and the growing list of webapps that support it, I could learn it from the tooltip on the search button if it included it (e.g., search topics, posts, users or categories ["/"]).

I finally got frustrated enough with the hijacking to search for an option to disable it and discovered this topic. I didnā€™t realize that I could get the browser search button to work if I pressed it twice. Good to know. At a bare minimum, it might be nice to let people know within the search boxā€¦ though it might be hard to fit along the bottom: [] Search this topic (press browser search key [Cmd+F] again to get the expected behavior). :wink:

As it stands, my menu is Chrome contains an entry Edit > Find > Find... āŒ˜F that behaves differently than pressing the indicated āŒ˜F shortcut. IMHO, this is a side effect of Discourse unnecessarily breaking established conventions.

3 Likes

Pressing CTRL (or CMD) + F twice to ā€œescapeā€ the Discourse search is a bit of a kludge because having focus on an input field disables standard keyboard shortcuts.

Technically, such a feature would be a wart, but it has been argued before that it is actually a miswart. The reason being that due to the infinite scroll mechanic, a large portion of the topic may not actually be available to the browser, so the browserā€™s built-in Ctrl+F cannot work correctly. :wink:

Oh, thereā€™s no misunderstanding from me on that. I absolutely get the reasons as to why itā€™s a good idea. The thing is, to me (and others, I suspect), the CTRL/CMD+F search paradigm is not about to change on the rest of the internet, so until Discourse proves the rest of the internet should change to follow their suit, then Iā€™d prefer if the functionality was not forcefully hijacked. Thatā€™s really all. My personal preference would be to use an alternative shortcut like ā€œ/ā€ (which now works, btw) and leave CTRL/CMD+F alone. Keyboard shortcuts have always been a ā€œpower userā€ thing anyway, so I donā€™t see this benefiting the average user as it is.

2 Likes

Yeah, youā€™re right, I too would prefer Ctrl+F to work as usual. In hindsight I guess I came across a bit strong, but I had been leafing through the jargon file (itā€™s history for nerds; awesome history) and couldnā€™t help but shove that wart comment in there. :sweat_smile:

1 Like

+1000 :smile:  

1 Like

couldnā€™t agree more. Iā€™m not sure why, but I donā€™t find the ctrl+f hijacking in google docs a problem, but it really irks me in discourse. I guess this is because gdocs mimics and extends the browser search with highlighting, [x] of [y] results and up/down arrows. If discourse was able to do this I think it would be less annoying.

1 Like

Personally I want to only enable the hijacking on the topic page, and not on topic lists like we have now, @codinghorror I really think this should be reconsidered, cause I actually use ā€œtraditionalā€ search on the other pages and we perform no unloading so there is not technical issue with enabling it.

That said ā€¦ about the topic page ā€¦

I 100% support hijacking of CTRL-F on topic pages. What would we call this user preference?

ā€œEnable extremely buggy browser search on topic pageā€

CTRL-F on topic pages is a trainwreck, open a composer hit CTRL-F its just totally messed up. As soon as you scroll to the spot it has highlighted it replaceState kicks in and clears the search results. Besides DOM unloading in larger topics which makes it simply look broken.

So, instead. I 100% support PRs to improve our in-topic search, perhaps oneā€™s that mimic more of built-in one (like scrolling to highlighted spot and dealing with multiple matches in one post and so on.

I also very much think we should stop hijacking in all other spots.

2 Likes

Thatā€™s a really really good point. I think this may be exactly why the Discourse implementation bothers me too.

This is very reasonable. I hope others will be able to help with this, because my ruby skills are next to non-existent (and I havenā€™t had much time to learn, or I would be doing so).

Probably fine, but I donā€™t think people are complaining about the topic list here.

I use Ctrl+F extensively to navigate topic lists on our (vBulletin) forum, and anticipate I will want to do the same after we move to Discourse, so Iā€™m very much with @sam on this.

If the hijacking is to remain within a topic - and I fully understand the arguments in favour of that - could the shortcut menu please be annotated to indicate this?

I first discovered the hijacking yesterday when I pressed Ctrl+F, started to type and then realised I had somehow opened the Discourse search box by mistake. So I closed it and tried again, with (of course) the same result. Long years of experience with poor co-ordination has taught me that when unexpected things happen, itā€™s because Iā€™ve hit the wrong keys by mistake, so I made a third attempt, carefully ensuring I got the intended keys, and only the intended keys. Still the search box opened. So I double-checked that I hadnā€™t accidentally activated Caps Lock, or any of the other things Iā€™ve been known to do, but no. I checked the keyboard shortcut menu to see if something had changed, but it still showed the search shortcut as ā€œ/ā€. At this stage, I then chose to open Discourse search, and discovered this and the related thread.

A brief note in the shortcut menu would have alerted me to this from the start and saved both time and frustration on my part.

1 Like

Press CTRL+F twice to get the browser native search. Warning: results can be bad on topic pages because stuff is unloaded from the browser DOM as you scroll.

2 Likes

Now thatā€™s a neat trick :smile:

I just amended it so we only hijack CTRL-F on topic pages, so this should no longer be a major issue.

2 Likes

I am sure plenty of jimmies will be rustled by having it on the topic page alone.

1 Like

ā€¦ just when I got used to Ctrl+F actually finding topics on the other pages.

Then again, thatā€™s just me, so donā€™t worry about it.

The actual shortcut ā€œ/ā€ still behaves in that manner, so you can still use it.

If thatā€™s a reply to my post, youā€™re missing the point. I was simply asking that the shortcut menu be amended to indicate that Ctrl+F will open the Discourse search from within a topic, to save the confusion folk like myself experience when things donā€™t work as expected.

2 Likes