diff --git a/internal/driver/html/stacks.js b/internal/driver/html/stacks.js index 5ed95345..c8059fe6 100644 --- a/internal/driver/html/stacks.js +++ b/internal/driver/html/stacks.js @@ -75,8 +75,12 @@ function stackViewer(stacks, nodes) { hiliter: (n, on) => { return hilite(n, on); }, current: () => { let r = new Map(); - for (let p of pivots) { - r.set(p, true); + if (pivots.length == 1 && pivots[0] == 0) { + // Not pivoting + } else { + for (let p of pivots) { + r.set(p, true); + } } return r; }}); @@ -174,7 +178,11 @@ function stackViewer(stacks, nodes) { function switchPivots(regexp) { // Switch URL without hitting the server. const url = new URL(document.URL); - url.searchParams.set('p', regexp); + if (regexp === '' || regexp === '^$') { + url.searchParams.delete('p'); // Not pivoting + } else { + url.searchParams.set('p', regexp); + } history.pushState('', '', url.toString()); // Makes back-button work matches = new Set(); search.value = ''; diff --git a/internal/driver/testdata/testflame.js b/internal/driver/testdata/testflame.js index 1040c60c..46f4e19f 100644 --- a/internal/driver/testdata/testflame.js +++ b/internal/driver/testdata/testflame.js @@ -87,6 +87,28 @@ function TestFlame() { checkWidth("F2", 100/100); checkWidth("F3", 100/100); }); + + test.run("NavigateWithoutPivot", function() { + // Clear pivot + boxMap.get("root").click(); + + // Trigger link update. + const btn = document.getElementById("graphbtn"); + if (!btn) { + test.err("no graph button on page"); + return; + } + const event = new Event("mouseenter"); + btn.dispatchEvent(event); + + // Check that URL does not contain a focus parameter. + test.log(btn.href); + const url = new URL(btn.href); + if (url.searchParams.has('f')) { + test.err("unexpected focus parameter in URL", btn.href); + } + }); + return test.result; } TestFlame();