diff --git a/packages/slate-react/src/utils/scroll-to-selection.js b/packages/slate-react/src/utils/scroll-to-selection.js index 49c7fce15..44c0f24f7 100644 --- a/packages/slate-react/src/utils/scroll-to-selection.js +++ b/packages/slate-react/src/utils/scroll-to-selection.js @@ -71,10 +71,11 @@ function scrollToSelection(selection) { xOffset = pageXOffset } else { const { offsetWidth, offsetHeight, scrollTop, scrollLeft } = scroller + const scrollerRect = scroller.getBoundingClientRect() width = offsetWidth height = offsetHeight - yOffset = scrollTop - xOffset = scrollLeft + yOffset = scrollTop - scrollerRect.top + xOffset = scrollLeft - scrollerRect.left } const top = (backward ? rect.top : rect.bottom) + yOffset