Skip to content

Commit 36e26f8

Browse files
Fix iframe reloadEditor no-op once fragment is on the URL (#11184)
This only applies in the iframe / no-cookie case as otherwise reload was already called. After one reloadEditor adds #editor, navigating to the same URL via location.assign(location.toString) doesn't actually reload as it's counted as a fragment navigation only. So it worked the first time only (e.g. when toggling keyboard controls you can only toggle once). This isn't an issue for micro:bit apps embedding MakeCode as they're same-site and go down the path that already reloaded, but confused me a lot when testing the iframe embedding in a non-same-site context. Co-authored-by: Richard Knoll <riknoll@users.noreply.github.com>
1 parent d93b4e7 commit 36e26f8

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

webapp/src/app.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2981,10 +2981,11 @@ export class ProjectView
29812981
if (hc) params.set("hc", "1");
29822982
else params.delete("hc");
29832983
}
2984+
// Need to add the URL parameters to the URL for the reload.
2985+
// Assigning to search will navigate on the first call but reload() needed
2986+
// for subsequent calls if there's a fragment (e.g. #editor).
29842987
location.search = params.toString();
2985-
// .reload refreshes without hitting server so it loses the params,
2986-
// so have to navigate directly
2987-
location.assign(location.toString());
2988+
location.reload();
29882989
} else {
29892990
location.reload();
29902991
}

0 commit comments

Comments
 (0)