elm / virtual-dom

The foundation of HTML and SVG in Elm.
https://package.elm-lang.org/packages/elm/virtual-dom/latest
BSD 3-Clause "New" or "Revised" License
209 stars 80 forks source link

Task not performed as expected during synchronous event processing #146

Open dynajoe opened 5 years ago

dynajoe commented 5 years ago

Here's a few examples of the problem:

A working example (expectation that time in milliseconds is displayed): https://ellie-app.com/3MrbG47yNZPa1

A failure example with the only difference being the addition of addition of onBlur NoOp to the text input:

https://ellie-app.com/3Mr9PQz7zvha1

Another failure example where the form is maintained in the DOM and the node that produced the Blur event is removed:

https://ellie-app.com/3MrmxXvLjfga1

The expectation is that in the two failure cases the Time.now Task is run.

Background

How I came about this issue in a real world example:

Here are examples of the stack around when the expected Task was produced:

Pressing Enter Key: image

Clicking Submit: image

stephenreddek commented 5 years ago

The second example will also work if you change onSubmit to be processed asynchronously by setting stopPropagation to False. So the code works with either an async form submit or with the removal of onBlur.

https://ellie-app.com/3MFQ9QnTgtVa1

decioferreira commented 4 years ago

This should now be solved with the new version elm/core@1.0.5. should this now be closed?