Implement backward and forward navigation options to iframed window (1.5 - accidentally closed) #191
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Note: This PR builds on the merged and soon-to-be-reverted PR #181 and removes the
set_iframe_scr
function andloaded
architecture so that the app navigates backward and forward seamlessly.Overview of changes
This PR adds backward and forward navigation options to iframed window. Because this sort of behavior isn't normally possible within the natural constraints of the History API since the history of the iframed window and that of its containing parent window operate together, I opted to manually track the history of the iframed window in two arrays—
history_bwd
andhistory_fwd
.Implementation/test cases & detailed steps for each
When any path is manually entered into the iframe's simulated address field… (expand to see details)
path
is appended tohistory_bwd
history_fwd
is resetpath
is naturally set to the entered path (current functionality)When the "back" button is clicked… (expand to see details)
path
is prepended tohistory_fwd
history_bwd
is sliced offpath
) replaces the currentpath
When the "forward" button is clicked… (expand to see details)
path
is appended tohistory_bwd
history_fwd
is sliced offpath
) replaces the currentpath
When any link within the iframe is clicked, it is picked up by
handle_message
which then falls back to using thenav_to
function for handling and tracking the history accordingly, effectively… (expand to see details)path
is appended tohistory_bwd
history_fwd
is resetpath
is naturally set to the entered path (current functionality)Notes
reset_history
function that resets the history, which I trigger in thetry
clause withinafterNavigate
.Testing
This can be tested/demoed effectively using any of the routing examples:
Screen recording
Screen.Recording.2023-01-23.at.11.51.15.AM.mov