Global view transitions for history restore #2873
Open
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.
Description
I added ViewTransitions to the restoreHistory function. In this pull request I only made this change when the user has enabled htmx.config.globalViewTransitions. This is as a PR for opening a discussion on this as anything else as I have some questions to the best approach for this work.
Screen.Recording.2024-09-06.at.12.05.21.mov
I understand that because this not a either a bugfix, a documentation update, or a new feature that has been explicitly approved via an issue. I apologise as I only saw those particular guideline
Questions
htmx.config.historyViewTransitions
?Idea
During development of this I had an idea but I thought it would be too big a PR and I wanted to start this initial discussion first, but I considered that it could be possible to add a transition flag into the history. This would be caught from the hx-swap of each request and mean that requests which updated the history, would also be able to play back the transition even without globalViewTransitions needing to be set (but then htmx.config.historyViewTransitions would make more sense)
Corresponding issue:
#1703
Testing
I tested this manually, switching on and off the
htmx.config.globalViewTransitions
flag. I ran the test suite locally and the linting rulesChecklist
master
for website changes,dev
forsource changes)
approved via an issue
npm run test
) and verified that it succeeded