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

persist nav state #209

Merged
merged 3 commits into from
Apr 1, 2021
Merged

Conversation

indirectlylit
Copy link
Contributor

@indirectlylit indirectlylit commented Mar 26, 2021

Description

Persist side nav bar scroll position and filter state using Window.sessionStorage, which should be per-tab.

Issue addressed

fixes #182

Before/after screenshots

before after
2021-03-26 16 45 54 2021-03-26 17 05 20

Steps to test

Experiment with navigation through the design system and see how it feels

(optional) Implementation notes

At a high level, how did you implement this?

  • Persists changes to state
  • Loads state on mounted

Does this introduce any tech-debt items?

  • Tries to keep the nav hidden until state has been loaded but doesn't always work as intended
  • There's a brief flash during page load

Reviewer guidance

  • Is the code clean and well-commented?
  • Are there tests for this change?
  • Are all UI components LTR and RTL compliant (if applicable)?
  • Add other things to check for here

Comments

Copy link
Member

@marcellamaki marcellamaki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be working as you describe and after just navigating around a bit, it definitely feels better to have the sidebar not lose its place. One thing I noticed was I found the search filter persisting after I hit the back button to be a bit surprising. I don't even know why this stood out to me - I just expected the filter to clear.

sidebar-search-filter

To me this isn't a blocker and the benefits of these updates outweigh this - mostly just sharing because I'm curious if someone knows about some design/UX convention where I may have subliminally picked this up 😆 Looks good, though!

@indirectlylit
Copy link
Contributor Author

Thanks for testing!

One thing I noticed was I found the search filter persisting after I hit the back button to be a bit surprising. I don't even know why this stood out to me - I just expected the filter to clear.

That's interesting, thanks. I debated doing it both ways and this seemed convenient for navigating within a group of related items ('button' was the filter term I used a lot.)

Let's raise it as a question/tension in the next tactical.

@indirectlylit indirectlylit merged commit 61b714f into learningequality:v0.2.x Apr 1, 2021
@indirectlylit
Copy link
Contributor Author

One idea: could persist trailing debounced changes (wait time ~2s) to the filter as query string changes and push them onto the browser history stack.

For example:

URL action
/ first URL
/?filter=button after enter 'button' into ToC filter
/kbutton?filter=button after clicking KButton entry
/?filter=button browser back
/ browser back

@nucleogenesis
Copy link
Member

<3

@indirectlylit
Copy link
Contributor Author

created follow-up issue here: #213

@indirectlylit indirectlylit deleted the nav branch April 12, 2021 19:00
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.

Would be nice if sidebar stayed static during navigation
3 participants