-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement new search shortcuts. #9337
Conversation
There are already keyboard shortcuts in the I think it would be confusing to add another mechanism. Of course another mechanism has already been added long ago with the left and right arrow keys being mapped by some JavaScript (but this is disabled by default in most themes). I think if shortcuts with "normal" letters are added, they should be added with the I guess an exception could be made for the "special" character In general, I'm not a fan of running some JavaScript that grabs my keypresses, mostly because I'm already using a browser extension (in my case https://github.com/tridactyl/tridactyl, but there are several similar ones) that watches my keypresses and reacts to In my own HTML theme I'm providing a BTW, the suggested change in this PR will also be disabled in most themes unless the sphinx/sphinx/themes/basic/static/doctools.js Lines 157 to 159 in 355937a
|
Good to know. It seems like a pretty standard mechanism, however, I see some limitations:
My inspiration was pages like Gmail, Trello or GitHub. Where shortcuts are pretty simple and easy to use.
Yes, one has to enable it explicitly.
That's pretty uncommon use to me. I prefer native shortcuts provided by a web page.
I like the other navigation shortcuts:
We can consider coming up with a more common name (shortcuts) and possibly enable it. |
Hmmm, it works for me on Chromium.
I very quickly got used to this, but I agree that it's not very straightforward. What's worse, it's hard to discover, it would be great if something could be done about this.
I don't understand.
Yeah, it's definitely a matter of preference. The question is: is it worth how much it helps users (like you) compared to how much it hurts other users (like me)? I think adding more shortcuts with |
I would like to extend the group of people who discuss the functionality. |
Nit-pick: consistent use of quotes -> I'd say single quotes instead of double quotes What are the remaining open questions? |
Sure, adjusted.
Apparently, @mgeier didn't like the idea. However, my patch only extends the existing useful shortcuts.
Is it something that can be addressed in the future once this pull request is merged? |
IMO, Note: I don't have an opinion to implement them because I'm not familiar with HTML and JS. |
Please merge the HEAD of 4.x branch to your PR to fix the CI error. It will be fixed soon. |
For illustration purposes, I've created #9539, showing hot |
Whatever the shortcut mechanism is (didn't know about accessKey) I like the addition of both search an clearing highlight. Though, it would be nice if it would clear the actual highlight, clear the highlight part of the URL, and all while not refreshing the page. I would also suggest to add a ? shortcut which shows an overview of shortcuts, e.g., like Gmail has. |
I've just done that. |
I think it's handy as e.g. |
I've just one that, browser history is updated accordingly.
That's exactly my use case why I came up with the pull request.
Great idea. Does Sphinx have any Overlay that can be used similarly to what Gmail or Github provides? |
Could you also update the documentation? See: https://www.sphinx-doc.org/en/master/usage/theming.html I don't think Sphinx has any overlay feature, and I'd suggest that the |
I've just done that.
Sure, works for me. |
I think it would be a bad idea to merge this as is. I personally don't like it when JavaScript grabs my key presses (because I'm using them for something else), but this is only one part of the problem. Even for people who maybe would like this exact implementation, they would still not get it in most cases, because Using And of course theme authors are free to support additional JavaScript keyboard shortcuts as they see fit. BTW, having this in the I do like the URL manipulation though, I think it would be great if this could be added to |
Heh.
I have an opposite idea as
But it has other problems (not being known, more complicated to use).
Sure, but it does not make sense to rename it or come up with a different one. I can read |
6c58f99
to
b7eb90d
Compare
Yes, I agree that one option would be better.
All fixed as I chose
Now it should work both on layouts where one needs Shift and one doesn't.
Can you please test it for me? Anyway, thanks for useful comments. |
6e09439
to
38403ea
Compare
Yeah, this is kinda hard to test, because it only works on RTD. I've added it on a (temporary) branch on this dormant project of mine: https://magic-call.readthedocs.io/en/sphinx-search-with-shortcuts/ It seems to work fine, AFAICT. The extension seems to not add the If you have a highlight link though (e.g. https://magic-call.readthedocs.io/en/sphinx-search-with-shortcuts/?highlight=package#the-python-package-magic-call) and then you hit I guess that's also a bug on their side, I've made a PR: readthedocs/readthedocs-sphinx-search#103. I couldn't test this though, because I couldn't manage to minify the thing. |
@mgeier Thank you for the testing effort! |
In the meantime I've found out that readthedocs-sphinx-search is already supposed to grab the |
Now that 4.4 has been released, can you rebase it on top of 4.x? And move the CHANGES entry correspondingly? |
- "/" for Focus search bar - "ESC" - clear highlighted text Fixes sphinx-doc#691. Co-authored-by: Jakob Lykke Andersen <[email protected]>
Done and moved CHANGES to the right place. Thanks for the approval. |
Is it time to merge this? I feel the discussion becomes too long. So how about merging this if you're okay. |
Given the thumbs-up reactions, looks like the answer is a yes. :) |
Yes, please merge it. |
Okay, merging now. Thank you for your contribution, all! |
Implement new shortcuts:
Fixes #691.