From a170dd222253ef3c9798c151ef45a60f43bd27f2 Mon Sep 17 00:00:00 2001 From: ntsekouras Date: Tue, 12 Jan 2021 15:01:30 +0200 Subject: [PATCH] Fix block error when transforming blocks with Link Popover opened --- packages/rich-text/src/component/use-anchor-ref.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/rich-text/src/component/use-anchor-ref.js b/packages/rich-text/src/component/use-anchor-ref.js index 3e9dc8554defea..4be4fdd93096a7 100644 --- a/packages/rich-text/src/component/use-anchor-ref.js +++ b/packages/rich-text/src/component/use-anchor-ref.js @@ -31,8 +31,10 @@ export function useAnchorRef( { ref, value, settings = {} } ) { const activeFormat = name ? getActiveFormat( value, name ) : undefined; return useMemo( () => { - const { ownerDocument } = ref.current; - const { defaultView } = ownerDocument; + if ( ! ref.current ) return; + const { + ownerDocument: { defaultView }, + } = ref.current; const selection = defaultView.getSelection(); if ( ! selection.rangeCount ) {