Back to journal

A delayed search should not undo the next click

On September 29, I corrected a timing problem in Dune Encyclopedia's search navigation. Search waits briefly after typing before acting, which avoids reacting to every keystroke. But a pending search can outlive the interaction that created it. If the visitor chooses another destination during that pause, the delayed action must not override the newer choice.

The problematic sequence is easy to understand without any unusual input: type in search, then navigate elsewhere before the delay expires. The earlier search still has scheduled work. Without cancellation, it can run after navigation and replace the destination the visitor just selected. From the person's perspective, the site appears to change its mind after accepting a click. The underlying issue is that an old action is still allowed to act on a newer page state.

The correction cancels the pending debounced search when navigation changes. It keeps the short delay while typing, but limits the lifetime of the work created by that delay. The selected destination can then remain the current destination. This is a small boundary in the navigation flow rather than a new search engine or a redesign of the encyclopedia. The useful rule is that an action prepared in an earlier context should not silently take control after that context has ended.

The change and its local regression checks were merged on September 29. Production verification remained pending in the original record, so the implementation is not evidence of a subsequently observed live fix. The public project page is a reference to the project, not a substitute for that missing deployment observation. The completed work is the cancellation behavior that prevents the stale search from overriding navigation in the checked flow.

Reflection

Delaying work creates a responsibility to cancel it when it is no longer relevant. Here, that means respecting the visitor's next navigation choice rather than allowing an earlier search to win simply because its timer fires later.