-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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> elements in an {#if} that depends on the input value do not fire on:input before they disappear #4225
Comments
Could you use Or just watch the Both of those approaches console logged the last empty value as expected for me. |
On Firefox, the final empty log does appear before the element is removed, if that means anything. It's unfortunate that the behavior differs between browsers, but it's really an edge case, and I can't really say which behavior I'd consider more correct. |
That works, however with this approach an input change event is never fired if the user just cuts all the text with
This is a good solution and seems to work in all cases. 👍 |
This reminds me of #3249 - possibly related? |
#3249 looks very similar to this issue. However, (if I understand that correctly) it is about a In #3249, the problem seems to be that the Also, if this comes down to the same underlying issue, I hope it is a bit easier to find with my more simple REPL. :-) (and I could reproduce #3249 in Firefox but as @Conduitry already discovered couldn't reproduce this issue in Firefox) |
putting the binding before the event listener causes the binding dependencies to update first |
Describe the bug
When you create an input that can be removed because of an if clause around it that depends on the input value, the last
on:input
event of the is not fired because it seems to disappear too quickly.Logs
To Reproduce
Minimal example: Remove the text in the input field character by character. For the last input event (the last BackSpace keystroke), no event is fired and
onInput
is not called.https://svelte.dev/repl/8d8bde660dea46f6b5443fe701cabd2b?version=3.16.7
Expected behavior
Before the input field disappears, one last input event is fired and
value:
is output into the console.Information about your Svelte project:
Browser: Google Chrome version 79.0.3945.88
Operating System: Windows 10
Svelte version: 3.16.7 (newest release)
Webpack or Rollup: not needed to reproduce the bug (REPL pad)
Severity
Not so high: It's just a bit confusing, as I would expect the last input event to fire. This can easily be fixed manually by using
display: none
CSS instead of a Svelte{#if}
clause.Manual fix with
display: none
demo (also demonstrating the expected behavior): https://svelte.dev/repl/78fd0c98c9cf4f3fab2c7e6f43cf7fe3?version=3.16.7The text was updated successfully, but these errors were encountered: