From f07f9aae97641ab80d1f4c95c6caa3d0a671f4be Mon Sep 17 00:00:00 2001 From: John Date: Fri, 15 Feb 2019 10:20:19 +0000 Subject: [PATCH] Check for empty range before creating undo record (#11209) window.getSelection() can return an empty range, causing getRangeAt() to fail --- packages/editor/src/components/rich-text/index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/editor/src/components/rich-text/index.js b/packages/editor/src/components/rich-text/index.js index 59ba6e6e4225c..ca4a598acb275 100644 --- a/packages/editor/src/components/rich-text/index.js +++ b/packages/editor/src/components/rich-text/index.js @@ -157,7 +157,8 @@ export class RichText extends Component { } createRecord() { - const range = getSelection().getRangeAt( 0 ); + const selection = getSelection(); + const range = selection.rangeCount > 0 ? selection.getRangeAt( 0 ) : null; return create( { element: this.editableRef,