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

Login page refreshes entire form when page hydrates, discarding any already-typed keypresses #110

Closed
rmunn opened this issue Jun 8, 2023 · 3 comments
Labels
bug Something isn't working Svelte owner: Robin
Milestone

Comments

@rmunn
Copy link
Contributor

rmunn commented Jun 8, 2023

Once the $t store from $lib/i18n loads its translations, the entire login page (and other forms as well, such as the create-project page, though I only captured a screenshot from the login page) refreshes itself, apparently creating new Svelte components. This ends up discarding any currently-entered text, as seen in the GIF below. (Note that to create this GIF, I commented out the await loadI18n(); line in hooks.client.ts, so that the $t store would fail to load any translations and would end up loading only the string keys. But this behavior still happens when the $t store is loading English, it's just a lot less obvious since the server-rendered page contains the same text as the $t-rendered page.

Peek 2023-06-08 13-09

NOTE: It's possible that it's not the $t store itself that's to blame, but rather Svelte-Kit's page hydration. Maybe before the page hydrates, I'm typing into DOM elements that then get replaced with the hydrated elements. If so, then we can't do all that much about it. But if it's the $t store changing that's causing the form elements to be replaced, it's possible that this is an issue we could fix.

@hahn-kev hahn-kev self-assigned this Jun 8, 2023
@myieye
Copy link
Contributor

myieye commented Jun 8, 2023

I think this is probably it sveltejs/svelte#1755

A new pain point of SSR + hydration.

@rmunn rmunn changed the title Login page refreshes entire page when i18n loaded, discarding any already-typed keypresses Login page refreshes entire form when page hydrates, discarding any already-typed keypresses Jun 23, 2023
@rmunn
Copy link
Contributor Author

rmunn commented Jun 23, 2023

Yep, the page takes a few seconds to load because it's making so many individual queries for GraphQL types, and so there's plenty of time to start typing an email address before hydration happens and replaces the <input> element with a new one.

@hahn-kev hahn-kev added the Svelte owner: Robin label Jun 28, 2023
@hahn-kev hahn-kev added this to the v1 milestone Jun 30, 2023
@hahn-kev hahn-kev removed their assignment Jul 7, 2023
@hahn-kev hahn-kev added the bug Something isn't working label Nov 22, 2023
@hahn-kev hahn-kev closed this as completed Dec 6, 2023
@myieye
Copy link
Contributor

myieye commented Dec 6, 2023

We fixed this by showing loading indicators instead of forms until hydration has happened.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Svelte owner: Robin
Projects
None yet
Development

No branches or pull requests

3 participants