Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Web viewer navigation (back-button) #5398

Closed
jprochazk opened this issue Mar 5, 2024 · 6 comments · Fixed by #5750
Closed

Web viewer navigation (back-button) #5398

jprochazk opened this issue Mar 5, 2024 · 6 comments · Fixed by #5750
Assignees
Labels
ui concerns graphical user interface 🕸️ web regarding running the viewer in a browser

Comments

@jprochazk
Copy link
Member

jprochazk commented Mar 5, 2024

We currently don't handle back/forward navigations in any way.

In practice, this means that:

  • A user sees a link to our web app, and clicks it
  • Scrolls down to the example section, and clicks on one of them
  • Looks at it for a bit
  • Navigates backward

This puts them back to where they were in the browser before navigation to app.rerun.io. That's quite a jarring experience.

The back button in the scenario above should've taken the user to the welcome screen, with the scroll position restored from before they opened the example. They may then either:

  1. Open a different example.
  2. Navigate forward to go back to the example they opened previously.

We should implement a navigation history within the viewer, mirroring the web history API.
What exactly requires an entry in the navigation history is somewhat unclear. We can start with only keeping track of navigations between the welcome screen and a recording, and between individual recordings when multiple are open at the same time.

We may eventually want to expand what we keep track of in the navigation history to more than just the welcome screen and recordings. For example, in Slack, clicking on "replies" under a post thread will "split" the main content area into the channel and reply thread (as long as there is enough space for both), where navigating back will close the thread, and subsequently navigating forward will re-open the thread.

@jprochazk jprochazk added the ui concerns graphical user interface label Mar 5, 2024
@nikolausWest
Copy link
Member

For the simple case here, would we drop the recording if you click and example on the welcome page, wait for recording to load, press back?

@emilk emilk added the 🕸️ web regarding running the viewer in a browser label Mar 12, 2024
@emilk emilk changed the title Viewer navigation Web viewer navigation (back-button) Mar 12, 2024
@jprochazk
Copy link
Member Author

As a first step, we should handle only navigations between the example page and recordings:

  • Opening a recording from the example page set a "navigated from example page" flag.
  • Pressing the back button when the "navigated from example page" flag is set will close all open recordings, effectively returning the user back to the example page.
  • Pressing the back button when the "navigated from example page" flag is not set will fall back to the browser default behavior, and on native do nothing.

This may introduce weird edge cases, but we're okay with that, because we just want the happy path of onboarding to work.

@nikolausWest
Copy link
Member

This is "high" urgency if it's a quick fix. Otherwise it's "medium"

@emilk
Copy link
Member

emilk commented Mar 25, 2024

Sounds like a good plan

@emilk
Copy link
Member

emilk commented Mar 28, 2024

We can also use the strategy of egui.rs and add #fragments to the url which is a real part of the history

@jprochazk jprochazk assigned emilk and unassigned jprochazk Apr 2, 2024
@emilk
Copy link
Member

emilk commented Apr 2, 2024

It seems like the best course of action would be to use the history API, as Jan suggested.

When leaving the examples/welcome page (clicking an example) we can call both:

history.pushState({}, "", "?examples");
history.pushState({}, "", "?url=…");

Then when the user hits the back-button, they will end up at ?examples (which we would need to parse and handle). When they press the forward button again, they end up at url=… which will load the example again.

We would need to install an even handler to listen for these changes with

window.addEventListener('popstate', function(event) {
   
})

emilk added a commit that referenced this issue Apr 3, 2024
### What
* Closes #5398

This uses the [History
API](https://developer.mozilla.org/en-US/docs/Web/API/History_API) to
manipulate the web history.

When leaving the example page, two entries in the history are added:

* `?examples` (shows the examples)
* `?url=https://….rrd` (the url for the example)

This is then parsed on `popstate`. We thus support both going forward
and back in history.

This is not perfect, but a lot better than before.

Best reviewed commit by commit.

### Checklist
* [x] I have read and agree to [Contributor
Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and
the [Code of
Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md)
* [x] I've included a screenshot or gif (if applicable)
* [x] I have tested the web demo (if applicable):
* Using newly built examples:
[rerun.io/viewer](https://rerun.io/viewer/pr/5750)
* Using examples from latest `main` build:
[rerun.io/viewer](https://rerun.io/viewer/pr/5750?manifest_url=https://app.rerun.io/version/main/examples_manifest.json)
* Using full set of examples from `nightly` build:
[rerun.io/viewer](https://rerun.io/viewer/pr/5750?manifest_url=https://app.rerun.io/version/nightly/examples_manifest.json)
* [x] The PR title and labels are set such as to maximize their
usefulness for the next release's CHANGELOG
* [x] If applicable, add a new check to the [release
checklist](https://github.com/rerun-io/rerun/blob/main/tests/python/release_checklist)!

- [PR Build Summary](https://build.rerun.io/pr/5750)
- [Docs
preview](https://rerun.io/preview/d308ce076b28481d77fac64217df69a452cc54a9/docs)
<!--DOCS-PREVIEW-->
- [Examples
preview](https://rerun.io/preview/d308ce076b28481d77fac64217df69a452cc54a9/examples)
<!--EXAMPLES-PREVIEW-->
- [Recent benchmark results](https://build.rerun.io/graphs/crates.html)
- [Wasm size tracking](https://build.rerun.io/graphs/sizes.html)

---------

Co-authored-by: Jeremy Leibs <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ui concerns graphical user interface 🕸️ web regarding running the viewer in a browser
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants