docsy icon indicating copy to clipboard operation
docsy copied to clipboard

Add a parameter to enable "live search"

Open homerduc opened this issue 8 months ago • 0 comments

Currently, local search with Lunr displays results when pressing enter, which in my opinion could feel weird, so for my project I wanted the search results to display each time the input text is modified. I struggled to find how to do this and the solution was to override the assets/js/offline-search.js file. Specifically the function from :

$searchInput.on('change', (event) => { render($(event.target));

  // Hide keyboard on mobile browser
  $searchInput.blur();
});

To :

$searchInput.on('input', (event) => { render($(event.target));

  // Hide keyboard on mobile browser
  $searchInput.blur();
});

I thought this could be added as a parameter since the default searchbar felt a bit odd to me. Hope I was clear :)

homerduc avatar May 09 '25 14:05 homerduc