Skip to content

Make expand/collapse-all button resilient to history changes #285

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

Merged
merged 5 commits into from
Jun 24, 2025

Conversation

kfranqueiro
Copy link
Contributor

Fixes #284.

This updates logic for the expand/collapse-all button to update showtechniques in the query string and synchronize the button's state with that query parameter. (This matches the existing behavior of expanding all, then collapsing a single technique, which evidently already has this effect.) This resolves the issue of browser back/forward buttons or links to anchors within main immediately losing the expand-all state.

Also in this PR, some cleanup:

  • Removed geturi which seemed to be completely unused, which further enabled removing everything related to localStorage
  • Consolidated new URI boilerplate to a single function
  • Changed noAddToHistory to a local variable at the top level of the jQuery ready function

Note that one particular detail of this implementation causes the expand/collapse-all button to no longer expand/collapse the "Show About & How to Use" button above the main area; I figured this is a net positive, as that would cause the button you just clicked to move, and it's another area that would end up in an inconsistent layout state as a result of the expand/collapse-all button.

Also note that the expand/collapse-all feature is still far from perfect; in particular, it is possible to get the show/hide description buttons out of sync with their state via a mix of direct interactions and interacting with the expand-all button. This is due to naive use of jQuery's toggle API; I'd like to think we shouldn't need that at all and should be able to tweak display based on CSS for the elements in question, but didn't want to open another entire can of worms right now.

@kfranqueiro kfranqueiro requested a review from iadawn June 3, 2025 21:37
@kfranqueiro kfranqueiro merged commit 5c7b4a8 into gh-pages Jun 24, 2025
@kfranqueiro kfranqueiro deleted the kgf-expand-all-fixes branch June 24, 2025 15:30
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.

Inconsistent state when using browser history after expanding all sections
2 participants