-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix scrolling to the inserted block issue in the iFramed block editor #31448
Changes from all commits
0eed49e
a1c2baa
2bc13fa
f4e7af0
691419e
782544a
24c57d7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you remove this file? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can't. This patch is needed. Without the patch it won't scroll upward, only downward. You can check the CodeSandbox example for a proof. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How des this file works? How it should be included when we move this code into Core? Should we propose a patch upstream instead? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, is this useful for the "template editor" or just the "site editor"? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is useful for anything that's iframed.
We have a "postinstall": "patch-package && node ./patches/patch-xcode.js",
I will bring this up in the code's repo. |
||
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think this should this be in the getScrollContainer function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we have the
dom-scroll-into-view
patched, it should work fine in all the other usages.But I'd rather not add it to
getScrollContainer
to let the consumer determine whether they still want to proceed on with the scroll or not. Just like in this case. I'm not familiar with the other usages ofgetScrollContainer
throughout the codebase.If we plan to move this into
getScrollContainer
, it would be better to experiment in a separate PR.