1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-22 23:12:52 +02:00

fix early ending of composition mode

This commit is contained in:
Ian Storm Taylor
2016-07-21 09:34:46 -07:00
parent 38eccfb436
commit 99146bc536

View File

@@ -58,6 +58,7 @@ class Content extends React.Component {
constructor(props) { constructor(props) {
super(props) super(props)
this.tmp = {} this.tmp = {}
this.tmp.compositions = 0
this.forces = 0 this.forces = 0
} }
@@ -148,6 +149,7 @@ class Content extends React.Component {
onCompositionStart = (e) => { onCompositionStart = (e) => {
this.tmp.isComposing = true this.tmp.isComposing = true
this.tmp.compositions++
} }
/** /**
@@ -160,8 +162,13 @@ class Content extends React.Component {
onCompositionEnd = (e) => { onCompositionEnd = (e) => {
this.forces++ this.forces++
const count = this.tmp.compositions
// The `count` check here ensures that if another composition starts
// before the timeout has closed out this one, we will abort unsetting the
// `isComposing` flag, since a composition in still in affect.
setTimeout(() => { setTimeout(() => {
if (this.tmp.compositions > count) return
this.tmp.isComposing = false this.tmp.isComposing = false
}) })
} }
@@ -267,7 +274,6 @@ class Content extends React.Component {
return return
} }
if ( if (
(key == 'enter') || (key == 'enter') ||
(key == 'backspace') || (key == 'backspace') ||