Skip to content
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: added workaround to prevent jumping viewport in bricks #25

Open
wants to merge 1 commit into
base: 10.6
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion bundles/AdminBundle/Resources/public/js/pimcore/overrides.js
Original file line number Diff line number Diff line change
Expand Up @@ -934,6 +934,18 @@ Ext.override(Ext.picker.Date, {
}
});

function isElementInTheViewport(domElement) {
if (domElement && typeof domElement.getBoundingClientRect === "function") {
const rect = domElement.getBoundingClientRect();
if (rect) {
return (
rect["top"] < window.innerHeight &&
rect["bottom"] > 0
);
}
}
return false;
}

/** workaround for [DataObject] Advanced Image Dropzone only works once #9115
* Issue: on node drop the component gets destroyed. On mouse up it then tries to focus an already destroyed element.
Expand All @@ -950,7 +962,9 @@ Ext.override(Ext.dom.Element, {
} else {
Ext.fireEvent('beforefocus', dom);
if (dom) {
dom.focus();
dom.focus({
preventScroll: isElementInTheViewport(dom)
});
}
}

Expand Down
Loading