Skip to content

Fix iframe reloadEditor no-op once fragment is on the URL#11184

Merged
riknoll merged 2 commits into
microsoft:masterfrom
microbit-matt-hillsdon:reload-fix
Mar 11, 2026
Merged

Fix iframe reloadEditor no-op once fragment is on the URL#11184
riknoll merged 2 commits into
microsoft:masterfrom
microbit-matt-hillsdon:reload-fix

Conversation

@microbit-matt-hillsdon
Copy link
Copy Markdown
Contributor

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.

Convincing yourself:

  1. Go to any website and run the following in the console watching for navigations:
  2. location.hash = "#editor" // hash only, no navigation
  3. location.search = "foo" // navigates
  4. location.assign(location.toString()) // does not navigate (but would without the hash step)

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.
@riknoll riknoll enabled auto-merge (squash) March 11, 2026 18:10
@riknoll riknoll merged commit 36e26f8 into microsoft:master Mar 11, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants