From f89eac2b875c4070cc7839fd4f2b96ebd9b17b43 Mon Sep 17 00:00:00 2001 From: Rainer Simon Date: Wed, 13 May 2020 08:36:57 +0200 Subject: [PATCH] Bugfix --- src/editor/Editor.jsx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/editor/Editor.jsx b/src/editor/Editor.jsx index 9475289..560f52d 100644 --- a/src/editor/Editor.jsx +++ b/src/editor/Editor.jsx @@ -2,9 +2,10 @@ import React from 'preact/compat'; import { useState, useRef, useEffect } from 'preact/hooks'; import setPosition from './setPosition'; -const autoApply = props => { - const applied = props.annotation.clone({ body: [{ ...props.autoApply }]}); - return applied.toAnnotation(); +/** We need to compare bounds by value, not by object ref **/ +const bounds = elem => { + const { top, left, width, height } = elem.getBoundingClientRect(); + return `${top}, ${left}, ${width}, ${height}`; } /** @@ -40,7 +41,7 @@ const Editor = props => { if (element.current) setPosition(props.wrapperEl, element.current, props.selectedElement); - }, [ props.selectedElement.getBoundingClientRect() ]); + }, [ props.selectedElement, bounds(props.selectedElement) ]); // Attach resize listener on mount useEffect(() => {