mirror of
https://github.com/ziglang/zig.git
synced 2026-02-14 13:30:45 +00:00
std docs: enhance search browser history UX
Before this change every keypress in the search field causes a browser history entry, which makes navigating back annoying. On first keypress in the search field, a new history entry is created. On subsequent keypresses, the most recent history entry is replaced. Therefore a typical history after searching and navigating to an entry might look like 1. documentation root 2. search page "print" 3. docs for `std.debug.print` Co-authored-by: Žiga Željko <ziga.zeljko@gmail.com>
This commit is contained in:
parent
545830c0ff
commit
c9ffb6f734
@ -1844,7 +1844,13 @@
|
||||
var oldHash = location.hash;
|
||||
var parts = oldHash.split("?");
|
||||
var newPart2 = (domSearch.value === "") ? "" : ("?" + domSearch.value);
|
||||
location.hash = (parts.length === 1) ? (oldHash + newPart2) : (parts[0] + newPart2);
|
||||
var newHash = (oldHash === "" ? "#" : parts[0]) + newPart2;
|
||||
// create a history entry only once per search
|
||||
if (parts.length === 1) {
|
||||
location.assign(newHash);
|
||||
} else {
|
||||
location.replace(newHash);
|
||||
}
|
||||
}
|
||||
function getSearchTerms() {
|
||||
var list = curNavSearch.trim().split(/[ \r\n\t]+/);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user