Set delay for typeahead search #4180
Labels
first-timers-only
They need to be well-formatted using the First-timers_Issue_Template.
fto-candidate
issues which are meant to be solved by first timers but aren't well-formatted yet
Hi, this is a first-timers-only issue built off #3472 . This means we've worked to make it more legible to folks who either haven't contributed to our codebase before, or even folks who haven't contributed to open source before.
If that's you, we're interested in helping you take the first step and can answer questions and help you out as you do. Note that we're especially interested in contributions from people from groups underrepresented in free and open source software!
We know that the process of creating a pull request is the biggest barrier for new contributors. This issue is for you 💝
If you have contributed before, consider leaving this one for someone new, and looking through our general help wanted issues. Thanks!
🤔 What you will need to know.
Nothing. This issue is meant to welcome you to Open Source :) We are happy to walk you through the process.
📋 Step by Step
🙋 Claim this issue: Comment below. If someone else has claimed it, ask if they've opened a pull request already and if they're stuck -- maybe you can help them solve a problem or move it along!
📝 Update the file restful_typeahead.js in the
plots2
repository (press the little pen Icon) and edit the line as shown below.See this page for some help in taking your first steps!
Here is where the change should be made:
plots2/app/assets/javascripts/restful_typeahead.js
Lines 10 to 21 in 5c9bb56
Below is a "diff" showing in red (and a
-
) which lines to remove, and in green (and a+
) which lines to add:var typeahead = $(el).typeahead({ items: 10, minLength: 3, + delay: 350, showCategoryHeader: true, autoSelect: false, source: function (query, process) { var encoded_query = encodeURIComponent(query); var qryType = $(el).attr('qryType'); return $.getJSON('/api/srch/' + qryType + '?query=' + encoded_query, function (data) { return process(data.items); },'json'); },
If you already have plots2 setup locally, you can also help us further test this issue!
Currently the 350 ms delay is based on pure speculation here.
You may set the delay to a desired number, then check out how many search requests are being made using your browser.
Start plots2
Then open up the inspector (Ctrl + shift + i in most browsers, or just right click and press inspect element).
Open up the "Network" tab.
Start typing in the search bar. Watch the search queries appear in the network tab.

We would like to have the least search queries as possible, but also not force the user to wait too long.
💾 Commit your changes
🔀 Start a Pull Request. There are two ways how you can start a pull request:
If you are familiar with the terminal or would like to learn it, here is a great tutorial on how to send a pull request using the terminal.
You can also edit files directly in your browser and open a pull request from there. Please make sure to insert the issue number into the PR.
🤔❓ Questions?
Leave a comment below!
Is someone else already working on this?
We encourage you to link to this issue by mentioning the issue # in your pull request, so we can see if someone's already started on it. If someone seem stuck, offer them some help! Otherwise, take a look at some other issues you can help with. Thanks!
(This issue was created by First-Timers-Bot.)
The text was updated successfully, but these errors were encountered: