regression commit: bec76f937c
In case when the user navigates away between async actions that code would error out on a missing element. This adds a simple sanity check.
This commit is contained in:
parent
2b53c2cfca
commit
6a389fd15a
|
@ -190,20 +190,21 @@ export default MountWidget.extend({
|
|||
refresh(() => {
|
||||
const refreshedElem = document.getElementById(elemId);
|
||||
|
||||
// Quickly going back might mean the element is destroyed
|
||||
const position = domUtils.position(refreshedElem);
|
||||
if (position && position.top) {
|
||||
let whereY = position.top - distToElement;
|
||||
document.documentElement.scroll({ top: whereY, left: 0 });
|
||||
|
||||
// This seems weird, but somewhat infrequently a rerender
|
||||
// will cause the browser to scroll to the top of the document
|
||||
// in Chrome. This makes sure the scroll works correctly if that
|
||||
// happens.
|
||||
schedule("afterRender", () => {
|
||||
document.documentElement.scroll({ top: whereY, left: 0 });
|
||||
});
|
||||
if (!refreshedElem) {
|
||||
return;
|
||||
}
|
||||
|
||||
const position = domUtils.position(refreshedElem);
|
||||
const top = position.top - distToElement;
|
||||
document.documentElement.scroll({ top, left: 0 });
|
||||
|
||||
// This seems weird, but somewhat infrequently a rerender
|
||||
// will cause the browser to scroll to the top of the document
|
||||
// in Chrome. This makes sure the scroll works correctly if that
|
||||
// happens.
|
||||
schedule("afterRender", () => {
|
||||
document.documentElement.scroll({ top, left: 0 });
|
||||
});
|
||||
});
|
||||
};
|
||||
this.topVisibleChanged({
|
||||
|
|
Loading…
Reference in New Issue