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

Input fields are cleared when JS finished loading #258

Closed
1 task done
Gerschtli opened this issue Aug 29, 2023 · 4 comments
Closed
1 task done

Input fields are cleared when JS finished loading #258

Gerschtli opened this issue Aug 29, 2023 · 4 comments

Comments

@Gerschtli
Copy link

Description

When the internet speed is fairly slow, JS is enabled and the user types in text into input fields, these values get reset as soon as the JS finished loading.

See the following screenshot of the final loading state when entering "test" into both input fields as soon as they were interactable while setting throttling to "Fast 3G".

Screenshot from 2023-08-29 16-29-24

If applicable, a MRE

I created https://github.com/Gerschtli/superforms-bug-input-values-reset-on-load to reproduce the issue (on stackblitz it was not reproducible).

  1. Run pnpm install
  2. Run pnpm dev -- --open
  3. On the page execute the described steps:
    1. Load this page with "Fast 3G" or similar
    2. Enter some values into both inputs immediately
    3. Wait for JS to be loaded completely and notice how the first input value is cleared (see also console.log statement)
@Gerschtli Gerschtli added the bug Something isn't working label Aug 29, 2023
@ciscoheat
Copy link
Owner

This is not a Superforms issue, but is more general; if you use bind:value with a normal variable, the same problem occurs.

@ciscoheat ciscoheat removed the bug Something isn't working label Aug 30, 2023
@Gerschtli
Copy link
Author

Oh, I am sorry, you are right. Will move it to the svelte repo!

@opack
Copy link

opack commented Oct 31, 2023

Hi! I am running into the exact same problem: in my tests, my form is reset after Playwright has already filled the values, and thus the subsequent expect fail because the form is reset at some point. If I add a pause, then everything is ok and the form is not reset. Here is a functioning test:

test('when password is too short', async ({ page, pom: { password } }) => {
	// Form is reset if the following line is removed
	await page.waitForTimeout(1000)
	await password.fill('short')
	await password.blur()
	await expect(page.getByText('String must contain at least 6 character(s)')).toBeVisible()
})

I understand that this issue is not caused directly by Superforms, but I did not find a relevant issue in Svelte or SvelteKit repos (maybe I missed it :-\ ).
@Gerschtli You said that you were going to move it to the svelte repo. Can you point me (and all the future people that will come here) to that very issue please, so that I can see what answer has been provided and maybe continue the discussion? Many thanks! 🙏

@opack
Copy link

opack commented Nov 2, 2023

To anyone passing by and wondering where this issue is, I finally found it 😄

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

No branches or pull requests

3 participants