fix: consistent location of search result

* fix 1098

* Update component.js

* Update component.js
This commit is contained in:
沈唁 2020-05-22 17:55:40 +08:00 committed by GitHub
parent c0d32805c9
commit e9dd2de384
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -171,11 +171,20 @@ function bindEvents() {
const $inputWrap = Docsify.dom.find($search, '.input-wrap');
let timeId;
// Prevent to Fold sidebar
/**
Prevent to Fold sidebar.
When searching on the mobile end,
the sidebar is collapsed when you click the INPUT box,
making it impossible to search.
*/
Docsify.dom.on(
$search,
'click',
e => e.target.tagName !== 'A' && e.stopPropagation()
e =>
['A', 'H2', 'P', 'EM'].indexOf(e.target.tagName) === -1 &&
e.stopPropagation()
);
Docsify.dom.on($input, 'input', e => {
clearTimeout(timeId);