FIX: Quirky scrolling position with keyboard use

This commit is contained in:
Robin Ward 2016-02-26 11:37:37 -05:00
parent 0af4d7cc20
commit c2c4eff08b
1 changed files with 16 additions and 0 deletions

View File

@ -59,7 +59,23 @@ export default Ember.Component.extend({
newTree._emberView = this;
const patches = diff(this._tree || this._rootNode, newTree);
const $body = $(document);
const prevHeight = $body.height();
const prevScrollTop = $body.scrollTop();
this._rootNode = patch(this._rootNode, patches);
const height = $body.height();
const scrollTop = $body.scrollTop();
// This hack is for when swapping out many cloaked views at once
// when using keyboard navigation. It could suddenly move the
// scroll
if (prevHeight === height && scrollTop !== prevScrollTop) {
$body.scrollTop(prevScrollTop);
}
this._tree = newTree;
if (this._afterRender) {