Skip to content

Commit 93c4360

Browse files
committed
playground: don't rewrite the URL bar when clicking examples
Clicking an example called history.replaceState to set ?cmd= to that command, so the address bar kept flipping between examples (e.g. grep then sed) as you tried them. Running an example shouldn't rewrite the URL out from under the user; the Copy share link button remains the way to turn the last command into a shareable ?cmd= URL.
1 parent f34ab93 commit 93c4360

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

static/js/playground.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -159,14 +159,13 @@ document.addEventListener("DOMContentLoaded", function() {
159159
el.innerHTML = parts.join(' · ');
160160
}
161161

162-
// Clickable examples: run the command and reflect it in the URL so it can
163-
// be shared/bookmarked.
162+
// Clickable examples: just run the command in the terminal. We deliberately
163+
// leave the address bar alone — running an example shouldn't rewrite ?cmd=
164+
// out from under the user. The "Copy share link" button is the way to turn
165+
// the last command into a shareable ?cmd= URL.
164166
document.querySelectorAll('.playground-example').forEach(function(btn) {
165167
btn.addEventListener('click', function() {
166168
var cmd = btn.textContent;
167-
var url = new URL(window.location.href);
168-
url.searchParams.set('cmd', cmd);
169-
window.history.replaceState(null, '', url);
170169
document.getElementById('wasm-playground').scrollIntoView({ behavior: 'smooth' });
171170
if (window.runInTerminal) {
172171
window.runInTerminal(cmd);

0 commit comments

Comments
 (0)