Page MenuHomePhabricator

D18052.diff
No OneTemporary

D18052.diff

diff --git a/webroot/rsrc/js/application/diff/DiffChangeset.js b/webroot/rsrc/js/application/diff/DiffChangeset.js
--- a/webroot/rsrc/js/application/diff/DiffChangeset.js
+++ b/webroot/rsrc/js/application/diff/DiffChangeset.js
@@ -501,12 +501,17 @@
// diff with a large number of changes don't constantly have the text
// area scrolled off the bottom of the screen until the entire diff loads.
//
- // There are two three major cases here:
+ // There are several major cases here:
//
// - If we're near the top of the document, never scroll.
- // - If we're near the bottom of the document, always scroll.
- // - Otherwise, scroll if the changes were above the midline of the
- // viewport.
+ // - If we're near the bottom of the document, always scroll, unless
+ // we have an anchor.
+ // - Otherwise, scroll if the changes were above (or, at least,
+ // almost entirely above) the viewport.
+ //
+ // We don't scroll if the changes were just near the top of the viewport
+ // because this makes us scroll incorrectly when an anchored change is
+ // visible. See T12779.
var target = this._node;
@@ -529,17 +534,18 @@
var target_pos = JX.Vector.getPos(target);
var target_dim = JX.Vector.getDim(target);
- var target_mid = (target_pos.y + (target_dim.y / 2));
+ var target_bot = (target_pos.y + target_dim.y);
- var view_mid = (old_pos.y + (old_view.y / 2));
- var above_mid = (target_mid < view_mid);
+ // Detect if the changeset is entirely (or, at least, almost entirely)
+ // above us.
+ var above_screen = (target_bot < old_pos.y + 128);
var frame = this._getContentFrame();
JX.DOM.setContent(frame, JX.$H(response.changeset));
if (this._stabilize) {
if (!near_top) {
- if (near_bot || above_mid) {
+ if (near_bot || above_screen) {
// Figure out how much taller the document got.
var delta = (JX.Vector.getDocument().y - old_dim.y);
JX.DOM.scrollToPosition(old_pos.x, old_pos.y + delta);

File Metadata

Mime Type
text/plain
Expires
Wed, Nov 6, 10:32 PM (6 d, 1 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6713050
Default Alt Text
D18052.diff (2 KB)

Event Timeline