virtual-dom icon indicating copy to clipboard operation
virtual-dom copied to clipboard

Task not performed as expected during synchronous event processing

Open dynajoe opened this issue 7 years ago • 2 comments

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:

  • Select text field and enter value
  • Press enter key
  • (Elm: Form submit)
  • (Elm: Initialize child component which produced a command to make an HTTP request)
  • Form disappears and child component is rendered in non-initialized state
  • (DevTools: Witnessed that a request WAS NOT made when pressing Enter)
  • (DevTools: Witnessed that request WAS made when clicking Submit on the form)

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

Pressing Enter Key: image

Clicking Submit: image

dynajoe avatar Nov 02 '18 01:11 dynajoe

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

stephenreddek avatar Nov 02 '18 14:11 stephenreddek

This should now be solved with the new version elm/[email protected]. should this now be closed?

decioferreira avatar Feb 19 '20 10:02 decioferreira