-
Notifications
You must be signed in to change notification settings - Fork 50.4k
Closed
Description
I'm trying to make a simple text box component with a suggestion feature.
However, in IE 11, there is an event that the Japanese IME conversion arbitrarily decides (I did not press the Enter key ...).
I examined it a little by myself, but this seems to have occurred only in IE 11, it seems that it has not occurred in other browsers such as Chrome and old Ver such as IE 10.
React version is 15.4.0.
There seemed to be similar issues in the past(https://github.com/facebook/react/issues/7027), but that bug has already been fixed.
Is this another bug? Or maybe I do not like how to make it?
/**
* SuggestTextBox
*/
const SuggestTextBox = React.createClass({
timer: null,
getInitialState: function(){
return {
focus : false,
suggestList : [],
value: ''
};
},
/**
* getSuggestListFromApi
*/
getSuggestListFromApi: function(value){
// Request API and get response
Common.apiCall({
type : 'GET',
url : '/api/hoge',
dataType : 'json',
data : {
Keyword: value
},
cache : false,
callback : function(result){
// set the state
this.setState({
suggestList: result.data.list,
activeItem: null
});
}.bind(this)
});
},
/**
* handleTextboxChange
*/
handleTextboxChange: function(e){
this.setState({
value: e.target.value,
suggestList: []
});
if (this.state.focus) {
if (e.target.value) {
if (this.timer) {
window.clearTimeout(this.timer);
}
this.timer = window.setTimeout(function(){
this.getSuggestListFromApi(e.target.value);
}.bind(this), 300);
}
}
},
/**
* handleFocus
*/
handleFocus: function(e){
this.setState({
focus: true
});
},
/**
* getSuggestNodes
*/
getSuggestNode: function(){
var listNode = this.state.suggestList.map(function(item, idx){
return (
<li
key={'fuga_suggestItem_'+item.id}
data-id={item.id}
data-name='fuga'
data-value={item.name}>
{item.name}
</li>
);
}.bind(this));
if (listNode.length > 0) {
return (
<ul className="suggestList">
{listNode}
</ul>
);
} else {
return null;
}
},
render: function(){
let suggestNode = this.getSuggestNode();
return (
<label>
<input
type="text"
name="fuga"
value={this.state.value}
onChange={this.handleTextboxChange}
onFocus={this.handleFocus} />
{suggestNode}
</label>
);
}
});
