Closed joelmukuthu closed 7 years ago
Upon further investigation, it seems this is a bug.
At first I couldn't reproduce it, see this gist.
But then I was able to, with this revision of the same gist.
The difference is the render function:
// works:
render() {
const {
focus
} = this.state;
return (
<button
onFocus={this.onFocus}
onBlur={this.onBlur}
className={focus ? 'focus' : 'no-focus'} />
);
}
// doesn't work
render() {
const {
focus
} = this.state;
return (
<div tabIndex='0' onFocus={this.handleFocus} onBlur={this.handleBlur}>
{focus &&
<div className='with-focus'>
<span>with focus</span>
</div>
}
</div>
);
}
i.e. the one that fails renders a new subtree if the element has focus.
I've just added the failing version of the gist to the repo regression tests, and all the tests passed. I'll try adding it to a fresh repo with dependencies installed normally.
Could you post the output of the test that fails?
:face_with_head_bandage: I was using an old version of the plugin (v3.1.2). It works fine with v3.3.2. Closing this, sorry for wasting time :)
No worries! Glad it's sorted. I'll add your test case to the repo anyway, good to have these sorts of issues validated that they don't return. Thanks for taking the time to create a repro case.
Great. No worries!
With
blur
, you'll want to first callonFocus
thenonBlur
to be sure that the thing is behaving as expected.I tried something like this:
which didn't work. But if I triggered the events myself then it worked:
Did I do something wrong or can this count as a feature request? :)