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 ellatrix committed May 11, 2019
1 parent 4108e37 commit 9c5bc04
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/format-library/src/link/inline.js
Original file line number Diff line number Diff line change
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 9c5bc04

Please sign in to comment.