From 1c8986019d82b4d7733d5b1da495fec6e3fba1e6 Mon Sep 17 00:00:00 2001 From: Ian Storm Taylor Date: Thu, 30 Jun 2016 18:58:07 -0700 Subject: [PATCH] fix double selecting --- lib/components/content.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/lib/components/content.js b/lib/components/content.js index 0566e16e2..a8046caa7 100644 --- a/lib/components/content.js +++ b/lib/components/content.js @@ -59,6 +59,33 @@ class Content extends React.Component { // ) } + /** + * While rendering set a flag, so that we can ignore any `select` events that + * fire because of the leaf nodes updating their selection. + * + * @param {Object} props + */ + + componentWillMount(props) { + this.tmp.isRendering = true + } + + componentWillUpdate(props) { + this.tmp.isRendering = true + } + + componentDidMount() { + setTimeout(() => { + this.tmp.isRendering = false + }) + } + + componentDidUpdate() { + setTimeout(() => { + this.tmp.isRendering = false + }) + } + /** * On before input, bubble up. * @@ -262,6 +289,7 @@ class Content extends React.Component { */ onSelect(e) { + if (this.tmp.isRendering) return if (this.tmp.isCopying) return let { state } = this.props