1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-22 15:02:51 +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) {
super(props)
this.tmp = {}
this.tmp.compositions = 0
this.forces = 0
}
@@ -148,6 +149,7 @@ class Content extends React.Component {
onCompositionStart = (e) => {
this.tmp.isComposing = true
this.tmp.compositions++
}
/**
@@ -160,8 +162,13 @@ class Content extends React.Component {
onCompositionEnd = (e) => {
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(() => {
if (this.tmp.compositions > count) return
this.tmp.isComposing = false
})
}
@@ -267,7 +274,6 @@ class Content extends React.Component {
return
}
if (
(key == 'enter') ||
(key == 'backspace') ||