News for hackers. Stuff that matters.
Re:How MDN's Autocomplete Search Works by bityard on Tuesday August 03, 2021 @01:33PM (#28051886)
They hi-jacked the browser's `/` key to focus the field, which is something I hate. As a user, I want `/` to bring up Firefox's quick search bar, especially when reading documentation.

They should have just had the search field focused automatically but that would have done away with their "clever" hack to lazy-load the DB containing every page name.

Also, I'm confused, I thought https://mdn.dev/ was the new thing because Mozilla was stepping back from MDN. Is it a fork? They both carry Mozilla logos, so what's going on there?

Re:How MDN's Autocomplete Search Works by est31 on Tuesday August 03, 2021 @01:47PM (#28052012)
Yeah discourse does the same. Sometimes i want to search within a post for some keyword. But ctrl+f redirects you to the global search... that global search only helps if you want to find interesting posts, but it does not support searching inside one, nor does it allow limited search within a thread. So I started using / in discourse discussions. Then that one was being overridden as well. I've heard the recommendation that you turn js off, which gives you a saner experience.
Re:How MDN's Autocomplete Search Works by mikepurvis on Tuesday August 03, 2021 @03:31PM (#28053121)
I hate this behaviour in discourse as well, but it hadn't occurred to me to try using it sans JS altogether, since it seemed to be pretty dependent on it. Will give that a shot for sure.
Re:How MDN's Autocomplete Search Works by polar on Tuesday August 03, 2021 @03:34PM (#28053147)
> But ctrl+f redirects you to the global search

Press ctrl-f twice.

Re:How MDN's Autocomplete Search Works by est31 on Tuesday August 03, 2021 @03:59PM (#28053425)
Oh thanks for that trick. It violates the principle of least surprise so much but it does what I want. Thanks again!
Re:How MDN's Autocomplete Search Works by chrismorgan on Tuesday August 03, 2021 @09:18PM (#28056213)
I sometimes use Ctrl+G (Find Again) to get around sites hijacking / or Ctrl+F when I want to use the browser’s search functionality: if the current search doesn’t match anything or if there is nothing to search for, then it opens the browser’s find bar. If that was hijacked too, you could still focus browser chrome (e.g. Ctrl+L, Ctrl+K, Alt+D and sometimes even others to focus the address/search bar) and then press Ctrl+F.
Re:How MDN's Autocomplete Search Works by thrdbndndn on Tuesday August 03, 2021 @02:34PM (#28052506)
I knew the existence of "/", but never figure out why I should use this instead of Ctrl+F. What's the difference (other than have fewer features)?
Re:How MDN's Autocomplete Search Works by kxrm on Tuesday August 03, 2021 @03:13PM (#28052930)
This seems to be a good introduction to Quick Find.

https://www.tenforums.com/tutorials/120679-enable-disable-qu...

Re:How MDN's Autocomplete Search Works by thrdbndndn on Tuesday August 03, 2021 @04:43PM (#28053934)
Ok, so the difference is:

1. It disappears after a few seconds.

2. It has no "next/previous/highlight all" etc. buttons (it still have these features, just no clickable buttons)

It still makes no sense to me.

I guess maybe a small portion of people would find the auto-disappearing thing useful, even though in normal Ctrl+F all you need to do is pressing Esc.

But the second "feature" totally baffles me. It's not like Ctrl+F is some expensive GUI to launch, why would I want to not have these buttons? Even if you don't need them at all (I don't), you can simply not click them, there is no downside by having them.

Re:How MDN's Autocomplete Search Works by lol768 on Tuesday August 03, 2021 @05:03PM (#28054197)
Does the usual Ctrl+F GUI support filtering down to links only?
Re:How MDN's Autocomplete Search Works by thrdbndndn on Tuesday August 03, 2021 @10:46PM (#28056638)
It doesn't, but "/" does not do that either. It's "'" that works that way (and obviously useful). I just don't know about "/".
Re:How MDN's Autocomplete Search Works by mejutoco on Tuesday August 03, 2021 @05:46PM (#28054640)
You can use the single quote character to search only links
Re:How MDN's Autocomplete Search Works by aabbcc1241 on Friday August 06, 2021 @08:11AM (#28086036)
And this has collision with my vim extension
Re:How MDN's Autocomplete Search Works by jannes on Tuesday August 03, 2021 @03:13PM (#28052926)
The only difference I know of is that "/" focuses links. So when you press return, it loads the link instead of jumping to the next result.

It's quite nice for keyboard-only web navigation.

Re:How MDN's Autocomplete Search Works by polar on Tuesday August 03, 2021 @03:33PM (#28053142)
> "/" focuses links.

It's ' to trigger quick find in links only mode.

Re:How MDN's Autocomplete Search Works by kxrm on Tuesday August 03, 2021 @03:48PM (#28053296)
I had the same confusion with his comment but I think what he meant was that when you highlight a result in a link, pressing enter causes you to follow that link (which is true). You are correct that ' focuses on only searching within links though.

Enter never goes to the next result though, so I am not sure if that is just something different between his setup and mine. I have to use F3 to go to the next result.

Re:How MDN's Autocomplete Search Works by jannes on Thursday August 05, 2021 @07:41AM (#28072335)
When I talked about enter going to the next result I was comparing it to the Ctrl+F search bar.

Sorry if that wasn't clear. (English is not my first language)

Re:How MDN's Autocomplete Search Works by jxcl on Tuesday August 03, 2021 @03:25PM (#28053060)
Firefox lets you disable keyboard overrides on a per-site basis, if that's something you're interested in

Page Info -> Permissions -> Override Keyboard Shortcuts

Re:How MDN's Autocomplete Search Works by peterbe on Tuesday August 03, 2021 @04:22PM (#28053677)
> They hi-jacked the browser's `/` key to focus the field, which is something I hate.

You're not the first one to point it out. Please join github.com/mdn/yari to raise your voice. It's an Open Source project after all.

> They should have just had the search field focused automatically

Why? There's a lot of JS to load to make that work. If you never need to do a search (e.g. from a Google search) it would be a potential waste.

> Also, I'm confused, I thought https://mdn.dev/ was the new thing because Mozilla was stepping back from MDN. Is it a fork?

That domain is just an alias we don't currently use. It's still the old MDN from Mozilla. No fork.

Re:How MDN's Autocomplete Search Works by daleharvey on Tuesday August 03, 2021 @04:59PM (#28054129)
> Why? There's a lot of JS to load to make that work. If you never need to do a search (e.g. from a Google search) it would be a potential waste.

Confused by what this comment is meant to say exactly, but just in case its not known already, seems this situation is what the autofocus attribute is for @ https://developer.mozilla.org/en-US/docs/Web/HTML/Global_att..., no JS needed

Re:How MDN's Autocomplete Search Works by deecewan on Wednesday August 04, 2021 @01:58AM (#28057684)
the op is saying "if we autofocussed, we'd need to load all the JS involved in performing the search"
Re:How MDN's Autocomplete Search Works by chrismorgan on Tuesday August 03, 2021 @09:20PM (#28056224)
> They should have just had the search field focused automatically

No, this would be extremely wrong: it’d open on-screen keyboards automatically on platforms that use them, mess with screen readers by dropping them in the search box rather than at the head of the page, and break keyboard functionality, most significantly things like arrow keys and Space for in-page navigation.

The autofocus attribute sometimes seems like a good idea, but it’s actually almost never desirable.

Re:How MDN's Autocomplete Search Works by Santosh83 on Tuesday August 03, 2021 @01:49PM (#28052023)
> Also, I'm confused, I thought https://mdn.dev/ was the new thing because Mozilla was stepping back from MDN. Is it a fork? They both carry Mozilla logos, so what's going on there?

It seems to me that mdn.dev is intended to be the future home of MDN web docs since it is collaborative now, and no longer exclusively managed by Mozilla. But they haven't actually made the transition yet, as any link on mdn.dev points back to the old (current) site at developer.mozilla.org

Re:How MDN's Autocomplete Search Works by jraph on Tuesday August 03, 2021 @04:11PM (#28053558)
GitHub and GitLab do this too. Is there a way to prevent web pages from hijacking this key? I almost never want to use their search engine and when I do, I'm fine with clicking on the input box.
Re:How MDN's Autocomplete Search Works by HWR_14 on Wednesday August 04, 2021 @01:46AM (#28057622)
> They hi-jacked the browser's `/` key to focus the field, which is something I hate.

This is one of the two comments on the article (the other being the rationale as a response for why they used the '/' key to do that behavior.)

Re:How MDN's Autocomplete Search Works by looperhacks on Wednesday August 04, 2021 @04:17AM (#28058553)
Great, even if I wanted to use this, I couldn't. On QWERTZ keyboards, you reach / by pressing Shift+7 which triggers the quick search bar but not the MDN field. Many programs use shortcuts like that and it really sucks.
Re:How MDN's Autocomplete Search Works by ushakov on Tuesday August 03, 2021 @01:35PM (#28051909)
imho, they should've opted for CMD/CTRL + K, which Algolia's Doc search uses

> They should have just had the search field auto-focused automatically but that would have done away with their "clever" hack to lazy-load the DB containing every page name.

this would steal away the focus and is not good for accessibility (unless you're building a search engine)