-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix scrolling to the inserted block issue in the iFramed block editor (…
…#31448) This PR patches the package by checking whether the container is an iframe window. In that case it scrolls the scrollingElement instead of the window. We can't scroll the iframe window because it's an iframe so the typical window.scrollTo() doesn't work.
- Loading branch information
1 parent
c8512db
commit 5dec957
Showing
2 changed files
with
28 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
diff --git a/node_modules/dom-scroll-into-view/lib/dom-scroll-into-view.js b/node_modules/dom-scroll-into-view/lib/dom-scroll-into-view.js | ||
index 557ed5c..23dfbad 100644 | ||
--- a/node_modules/dom-scroll-into-view/lib/dom-scroll-into-view.js | ||
+++ b/node_modules/dom-scroll-into-view/lib/dom-scroll-into-view.js | ||
@@ -21,6 +21,7 @@ function scrollIntoView(elem, container, config) { | ||
allowHorizontalScroll = allowHorizontalScroll === undefined ? true : allowHorizontalScroll; | ||
|
||
var isWin = util.isWindow(container); | ||
+ var isFramed = !!(isWin && container.frameElement); | ||
var elemOffset = util.offset(elem); | ||
var eh = util.outerHeight(elem); | ||
var ew = util.outerWidth(elem); | ||
@@ -35,7 +36,11 @@ function scrollIntoView(elem, container, config) { | ||
var ww = undefined; | ||
var wh = undefined; | ||
|
||
- if (isWin) { | ||
+ if (isFramed) { | ||
+ container = container.document.scrollingElement || container.document.body; | ||
+ } | ||
+ | ||
+ if (isWin || isFramed) { | ||
win = container; | ||
wh = util.height(win); | ||
ww = util.width(win); |