mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
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(() => {
|
refresh(() => {
|
||||||
const refreshedElem = document.getElementById(elemId);
|
const refreshedElem = document.getElementById(elemId);
|
||||||
|
|
||||||
// Quickly going back might mean the element is destroyed
|
if (!refreshedElem) {
|
||||||
const position = domUtils.position(refreshedElem);
|
return;
|
||||||
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 });
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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({
|
this.topVisibleChanged({
|
||||||
|
Loading…
Reference in New Issue
Block a user