fix: resolve iframe synchronization timing issue between load and click events#303
fix: resolve iframe synchronization timing issue between load and click events#303Raakshass wants to merge 1 commit into
Conversation
…ck events Signed-off-by: Siddhant Jain <siddhantjainofficial26@gmail.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
There was a problem hiding this comment.
Pull request overview
Fixes iframe URL synchronization between parent dashboard and embedded iframe content by addressing a timing issue where this.page was not initialized on iframe load, and removing a re-entrant hash update that caused incorrect URL state.
Changes:
- Initialize
this.pagefrom the iframe's current location inside theloadevent handler before attaching click/hashchange listeners. - Remove the redundant
this.set('routeHash.path', ...)call afterwindow.history.replaceStatein_iframePageChanged. - Drop two now-invalid
expect(page).toBe(undefined)assertions in the iframe-container tests.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| components/centraldashboard/public/components/iframe-container.js | Set this.page from the iframe's location on each load event |
| components/centraldashboard/public/components/main-page.js | Remove re-entrant routeHash.path set causing stale URL updates |
| components/centraldashboard/public/components/iframe-container_test.js | Remove stale undefined assertions invalidated by load-time page init |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
/hold Can you resolve/address this comment from the original PR - at which point we could consider re-reviewing and approving this: |
|
@andyatmiami addressing your request from #141 (comment).
|
summary
takes ownership of #141 (original author @hahahannes, inactive since August 2025). re-applied the fix on current main with failing unit tests fixed.
closes #65
root cause
the iframe-container's
loadevent listener attaches click and hashchange handlers but does not setthis.pagefrom the loaded iframe's current location. when a non-client-side navigation occurs inside the iframe (server-side redirect / GET request), the click event fires before the page property is initialized, causing the parent URL to either not update or update to a stale value.additionally,
_iframePageChangedin main-page.js callsthis.set('routeHash.path', ...)afterwindow.history.replaceState. this triggers the_routePageChangedobserver a second time, creating a re-entrant state loop that produces incorrect URL synchronization.fix
iframe-container.js: set
this.pagefrom the iframe's location on theloadevent, before attaching click/hashchange listeners. this ensures the page property is always initialized to the current iframe location after navigation.main-page.js: remove the redundant
this.set('routeHash.path', ...)call.window.history.replaceStatealready updates the URL. the hash is reflected through the load event sync, making the explicit set unnecessary and harmful.iframe-container_test.js: remove two
expect(page).toBe(undefined)assertions. with the load-time sync, page is no longer undefined after beforeEach completes — it is set to the loaded iframe's path. the remaining assertions (click and hashchange update page to the expected value) are preserved.changes
components/centraldashboard/public/components/iframe-container.jsthis.pagefrom iframe location on load eventcomponents/centraldashboard/public/components/main-page.jsrouteHash.pathset in_iframePageChangedcomponents/centraldashboard/public/components/iframe-container_test.jsundefinedassertions for page propertywhat is not changed
cc @juliusvonkohout @andyatmiami @thesuperzapper