-
Notifications
You must be signed in to change notification settings - Fork 4k
Closed
Labels
bugIssue reports a bugIssue reports a bug
Description
Search shortcut breaks forms
We have a number of forms in our mkdocs site which are broken by the search shortcut (s / f).
Expected behavior
Search only opens when not focused on a form element.
Actual behavior
When typing in a form field (e.g. input / text area) an s or f will open the search.
Steps to reproduce the bug
- Add the following to a test page
<form>
<input></input>
<textarea></textarea>
</form>
- Attempt to write
sausagesin the input / text area
Package versions
- Python:
Python 2.7.13 - MkDocs:
0.16.3 - Material:
1.7.4
Potential fix
I think the code to fix this would be a change to: https://github.com/squidfunk/mkdocs-material/blob/master/src/assets/javascripts/application.js#L340
Something like this to check if the current focused element is part of a form:
if (document.activeElement.form === undefined) {
if (ev.keyCode === 70 || ev.keyCode === 83) {
query.focus()
ev.preventDefault()
}
}That seems to work in testing but doesn't pass the 'flow' check and I'm not quite familiar enough with js to quickly make this work.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugIssue reports a bugIssue reports a bug