mirror of https://github.com/vector-im/riot-web
fix NPE and make enter work again
parent
e4671205d8
commit
8e9e33fa2a
|
@ -154,6 +154,7 @@ module.exports = React.createClass({
|
||||||
//ev.target.setSelectionRange(0, ev.target.textContent.length);
|
//ev.target.setSelectionRange(0, ev.target.textContent.length);
|
||||||
|
|
||||||
var node = ev.target.childNodes[0];
|
var node = ev.target.childNodes[0];
|
||||||
|
if (node) {
|
||||||
var range = document.createRange();
|
var range = document.createRange();
|
||||||
range.setStart(node, 0);
|
range.setStart(node, 0);
|
||||||
range.setEnd(node, node.length);
|
range.setEnd(node, node.length);
|
||||||
|
@ -161,14 +162,16 @@ module.exports = React.createClass({
|
||||||
var sel = window.getSelection();
|
var sel = window.getSelection();
|
||||||
sel.removeAllRanges();
|
sel.removeAllRanges();
|
||||||
sel.addRange(range);
|
sel.addRange(range);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onFinish: function(ev) {
|
onFinish: function(ev) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
var submit = (ev.key === "Enter");
|
||||||
this.setState({
|
this.setState({
|
||||||
phase: this.Phases.Display,
|
phase: this.Phases.Display,
|
||||||
}, function() {
|
}, function() {
|
||||||
self.onValueChanged(ev.key === "Enter");
|
self.onValueChanged(submit);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue