Skip to content

Commit

Permalink
Check for selection range count before calling getRangeAt (#15576)
Browse files Browse the repository at this point in the history
  • Loading branch information
gwwar authored and youknowriad committed May 15, 2019
1 parent 1d09dde commit 730d791
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/format-library/src/link/inline.js
Expand Up @@ -79,7 +79,8 @@ const LinkViewerUrl = ( { url } ) => {

const URLPopoverAtLink = ( { isActive, addingLink, value, ...props } ) => {
const anchorRect = useMemo( () => {
const range = window.getSelection().getRangeAt( 0 );
const selection = window.getSelection();
const range = selection.rangeCount > 0 ? selection.getRangeAt( 0 ) : null;
if ( ! range ) {
return;
}
Expand Down

0 comments on commit 730d791

Please sign in to comment.