Search that settles on the wrong word
Type an ingredient at a normal pace and the results land on a word you passed through three keystrokes ago.
nextChewy~30 min
1
Fresh from the oven
Clone it down and have a look around.
$
git clone https://github.com/loaf-crumbs/search-settles-on-the-wrong-word.git2
The scenario
The Loaf store has a pantry search: one box, results update live as you type. Each keystroke fires a request to `/api/search` and the matches drop in underneath.
Type a single ingredient at a normal pace — `sourdough`, say — and watch where it ends up. The box reads `sourdough`, but the list under it fills with a broad jumble of items, and the counter cheerfully reports the matches "for sourdough" even though half of them have no sourdough in them. Stop typing, wait a second, and it stays wrong. Type the same word slowly, one letter at a time with a pause between each, and it's perfect.
Every search, on its own, returns exactly the right matches — you can confirm that by hitting `/api/search?q=sourdough` directly. The list only goes wrong when the letters come fast.
3
What done looks like
- Typing a query quickly leaves the results matching the final word in the box, not an earlier one
- The match count and the listed items always agree with what the box currently says
- Searching fast and searching slowly produce the same final results
4
Stuck?
Peek if you need to — they get more specific as you go.
5
Taste test
Send it in when you’re ready. We’ll see if it’s tasty.
When you've got the flag, paste it here.
No attempts yet.