-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Fix: Retain focus for persisted input elements during view transitions #8813
Conversation
🦋 Changeset detectedLatest commit: 2f8965e The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really related to focus handling, but as I was going through the tests I noticed that we are running with output = server
, when in fact almost all tests are static. So I marked the test that needs the server with prerender = false
and changed to hybrid
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The file was always called styles.css
, but I noticed it only now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems great, thanks for the fix and detailed test!
Changes
An element with
transition:persist
survives view transitions and continues its life on the next page. Its state is preserved. For example, aHTMLTextAreaElement
retains the text entered up to that point. Unfortunately, persisted elements lose focus during the transition when they are removed from the DOM and reinserted.This fix saves the current focus and cursor position and restores them on the new page.
Testing
Added e2e test
Docs
n/a bug fix