From 5afcdd3c975548c47a15784261631760dbea4a49 Mon Sep 17 00:00:00 2001 From: Ian Storm Taylor Date: Sat, 28 Oct 2017 15:29:01 -0700 Subject: [PATCH] fix flush change logic to not stack flushes (#1324) --- packages/slate-react/src/components/editor.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/slate-react/src/components/editor.js b/packages/slate-react/src/components/editor.js index ae1a887d7..cb111ae4f 100644 --- a/packages/slate-react/src/components/editor.js +++ b/packages/slate-react/src/components/editor.js @@ -181,10 +181,11 @@ class Editor extends React.Component { flushChange = () => { const { change } = this.tmp - if (change) { + if (change && !this.tmp.flushTimeout) { debug('flushChange', { change }) - window.requestAnimationFrame(() => { + this.tmp.flushTimeout = setTimeout(() => { delete this.tmp.change + delete this.tmp.flushTimeout this.props.onChange(change) }) }