From 9ae96b9e174d2c61d760d5220b4113e75adac061 Mon Sep 17 00:00:00 2001 From: Kirk Douglas Jr Date: Mon, 13 Mar 2023 15:09:04 -0600 Subject: [PATCH] fix(move-up-tune): scroll up offset for blocks above viewport (#2298) * fix: scroll up offset for blocks above viewport * Update CHANGELOG.md * Update CHANGELOG.md --------- Co-authored-by: Peter Savchenko --- docs/CHANGELOG.md | 1 + src/components/block-tunes/block-tune-move-up.ts | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 996914d3..4b677d9a 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -6,6 +6,7 @@ - `Improvement` — *Toolbox* — Number of `close()` method calls optimized. - `Improvement` — The `onChange` callback won't be triggered only if all mutations contain nodes with the `data-mutation-free` attributes. - `Fix` — Resolve compiler error from importing the BlockToolData type +- `Fix` — Resolved a problem when document was being scrolled to the beginning after moving up a Block above the viewport ### 2.26.5 diff --git a/src/components/block-tunes/block-tune-move-up.ts b/src/components/block-tunes/block-tune-move-up.ts index 242cd83f..36f645f4 100644 --- a/src/components/block-tunes/block-tune-move-up.ts +++ b/src/components/block-tunes/block-tune-move-up.ts @@ -82,7 +82,7 @@ export default class MoveUpTune implements BlockTune { if (previousBlockCoords.top > 0) { scrollUpOffset = Math.abs(currentBlockCoords.top) - Math.abs(previousBlockCoords.top); } else { - scrollUpOffset = window.innerHeight - Math.abs(currentBlockCoords.top) + Math.abs(previousBlockCoords.top); + scrollUpOffset = Math.abs(currentBlockCoords.top) + previousBlockCoords.height; } window.scrollBy(0, -1 * scrollUpOffset);