Skip to content

Add 'email' to list of fields where s is not a shortcut for search #1569

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

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/theme/searcher/searcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ window.search = window.search || {};

// Eventhandler for keyevents on `document`
function globalKeyHandler(e) {
if (e.altKey || e.ctrlKey || e.metaKey || e.shiftKey || e.target.type === 'textarea' || e.target.type === 'text') { return; }
if (e.altKey || e.ctrlKey || e.metaKey || e.shiftKey || e.target.type === 'textarea' || e.target.type === 'text' || e.target.type === 'email') { return; }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of wack-a-mole on the on the input types, perhaps something like this would work?

!hasFocus() && /^(?:input|select|textarea)$/i.test(e.target.nodeName)

Copy link
Contributor

@notriddle notriddle Jun 12, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<input type=checkbox>, radio, submit do not accept arbitrary keyboard input, and should probably allow the search shortcut.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

!hasFocus() && /^(?:input|select|textarea)$/i.test(e.target.nodeName) worked for me. I have a sign-up and login form, which otherwise I couldn't type s. When adding the above, it works perfectly fine. I would love to get this merged to avoid building myself every time.


if (e.keyCode === ESCAPE_KEYCODE) {
e.preventDefault();
Expand Down