mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 22:26:26 +08:00
FIX: Prevent content layout shift on mobile (#26238)
This commit is contained in:
parent
4f24e3b3b2
commit
0bf87c5ed8
|
@ -206,15 +206,18 @@ export default MountWidget.extend({
|
|||
return element.offsetTop + getOffsetTop(element.offsetParent);
|
||||
};
|
||||
|
||||
const top = getOffsetTop(refreshedElem) - offsetCalculator();
|
||||
window.scrollTo({ top });
|
||||
window.scrollTo({
|
||||
top: getOffsetTop(refreshedElem) - offsetCalculator(),
|
||||
});
|
||||
|
||||
// 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", () => {
|
||||
window.scrollTo({ top });
|
||||
window.scrollTo({
|
||||
top: getOffsetTop(refreshedElem) - offsetCalculator(),
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue
Block a user