Skip to content

Commit

Permalink
Check for empty range before creating undo record (#11209)
Browse files Browse the repository at this point in the history
window.getSelection() can return an empty range, causing getRangeAt() to fail
  • Loading branch information
johngodley authored and youknowriad committed Mar 6, 2019
1 parent be5a016 commit 1010e46
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/editor/src/components/rich-text/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 1010e46

Please sign in to comment.