Answer the question
In order to leave comments, you need to log in
How do you solve the onBlur/onFocus problem?
You hang onBlur / onFocus on the element and when you click on the element (child) again, the focus and blur work once again breaking my drop-down datepicker It's clear that there are other ways to solve the problem, but with blur / focus it would seem more logical
render: function () {
var component = this;
var props = component.props;
var state = component.state;
return (
<div>
<label onFocus={component.onOpenDateRangePicker} onBlur={component.onCloseDateRangePicker}>
<input
className="date-range-picker-input"
value={component.state.value}/>
<div className={classNames('date-picker-wrapper', {hidden: !state.isOpened})}>
<DateRangePicker />
</div>
</label>
</div>
);
},
onOpenDateRangePicker: function (event) {
var component = this;
debugger;
component.setState({
isOpened: true
});
console.log('focus');
},
onCloseDateRangePicker: function (event) {
var component = this;
debugger;
component.setState({
isOpened: false
});
console.log('blur');
}
Answer the question
In order to leave comments, you need to log in
Try putting onFocus/onBlur on input.
I just checked in my application and I do not observe such an effect.
Check the real target of the event, something like this:
if(event.target.localName != 'input')
return;
https://jsfiddle.net/wxm0087c/
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question