flux icon indicating copy to clipboard operation
flux copied to clipboard

Call setState onBlur stops event propagation, necessary to use window.setTimeout? or Bug in Flux?

Open justin808 opened this issue 12 years ago • 2 comments

I have an callback for onBlur that will setState, and based on the state, some buttons may be removed from the screen.

The problem is that one of these buttons has a callback that needs to run, and if setState is called from the onBlur callback, then the callback for the button does not run, probably because it's not technically visible. I verified that the button callback works fine if the onBlur callback does not call setState.

I worked around the issue by using a window.setTimout that calls setState after 250ms.

  • Is this the right approach?
  • Or is this a bug in flux that all callbacks don't run?

My expectation is that the all callbacks would run and the setState calls would be cummulative.

Thanks for any advice.

justin808 avatar Oct 04 '14 10:10 justin808

In what way does this involve the actions, dispatcher or stores?

On Saturday, October 4, 2014, Justin Gordon [email protected] wrote:

I have an callback for onBlur that will setState, and based on the state, some buttons may be removed from the screen.

The problem is that one of these buttons has a callback that needs to run, and if setState is called from the onBlur callback, then the callback for the button does not run, probably because it's not technically visible. I verified that the button callback works fine if the onBlur callback does not call setState.

I worked around the issue by using a window.setTimout that calls setState after 250ms.

  • Is this the right approach?
  • Or is this a bug in flux that all callbacks don't run?

My expectation is that the all callbacks would run and the setState calls would be cummulative.

Thanks for any advice.

— Reply to this email directly or view it on GitHub https://github.com/facebook/flux/issues/73.

fisherwebdev avatar Oct 04 '14 16:10 fisherwebdev

Oh! Sorry, I need to put this in the React repo. Late at night when I filed this.

justin808 avatar Oct 04 '14 18:10 justin808