-
Notifications
You must be signed in to change notification settings - Fork 47.4k
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
Call setState onBlur stops event propagation, necessary to use window.setTimeout? or Bug in Flux? #2291
Comments
Hey @justin808 , could you please provide an example? In this example you can see that both of the callbacks get fired as expected. I also added a second click button that fired multiple setState in sequence and commented what's going on behind (what drives the behavior of overriding the property is this merge between _pendingState and partialState). I don't know if this was exactly your question (if this does not helps you, i hope it helps someone 😄 ) Regarding the questions, check this comment on
|
Hi @cirocosta, I changed my UI around. I don't have any more to share than the original comment. I'm 100% sure that setting the state from the onBlur, which set a state such that a button would not display, would result in the button's onClick from being called. |
It appears that this is still an issue. We encountered this while trying to have different parts of form validation happen on both the onBlur and the onClick. It seems that if you change the DOM with some state effected by the onBlur, when it is ABOVE the button containing the onClick, the onclick will not fire. See this http://jsfiddle.net/kb3gN/11477/ which is a variation on the example provided above. If you enter some text, you'll have to click the button twice, to see click: true. Will create a new issue and reference this one. |
I'm seeing this issue where a |
The issue of setState in onBlur preventing other click events is still happening. |
I have an input with onBlur and a menu whith onClick like this: <input onBlur={handleBlur} />
<Menu onClick={handleClick} /> when setState in handle blur, the handle Click will not fire |
If there is still an issue please file a new issue with a minimal repro case. Commenting in closed issues is not helpful — there are thousands of them and nobody is keeping track. |
I have an callback for onBlur that will call 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, as the onBlur was caused by clicking on that button. If setState is called from the onBlur callback, then the callback for the button (onClick) does not run, maybe 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.
The text was updated successfully, but these errors were encountered: