Do not set focus on cursor target following diff scroll
The diff cursor suspends the underlying cursor's scroll behavior while the diff is rendering if the user scrolls the page before the render is complete. However, when focus-on-move is enabled, the underlying cursor also sets focus and this causes a scroll anyway. With this change the cursor manager suspends the focus-on-move in the same way that it suspends the scroll behavior to prevent this unwanted scroll/focus. Bug: Issue 7390 Change-Id: I2bc7a06e940475b6b3c94995494f4207902acb40
This commit is contained in:
@@ -23,7 +23,7 @@ limitations under the License.
|
||||
id="cursorManager"
|
||||
scroll-behavior="[[_scrollBehavior]]"
|
||||
cursor-target-class="target-row"
|
||||
focus-on-move
|
||||
focus-on-move="[[_focusOnMove]]"
|
||||
target="{{diffRow}}"></gr-cursor-manager>
|
||||
</template>
|
||||
<script src="gr-diff-cursor.js"></script>
|
||||
|
||||
@@ -80,6 +80,11 @@
|
||||
value: ScrollBehavior.KEEP_VISIBLE,
|
||||
},
|
||||
|
||||
_focusOnMove: {
|
||||
type: Boolean,
|
||||
value: true,
|
||||
},
|
||||
|
||||
_listeningForScroll: Boolean,
|
||||
},
|
||||
|
||||
@@ -207,6 +212,7 @@
|
||||
_handleWindowScroll() {
|
||||
if (this._listeningForScroll) {
|
||||
this._scrollBehavior = ScrollBehavior.NEVER;
|
||||
this._focusOnMove = false;
|
||||
this._listeningForScroll = false;
|
||||
}
|
||||
},
|
||||
@@ -218,6 +224,7 @@
|
||||
this.reInitCursor();
|
||||
}
|
||||
this._scrollBehavior = ScrollBehavior.KEEP_VISIBLE;
|
||||
this._focusOnMove = true;
|
||||
this._listeningForScroll = false;
|
||||
},
|
||||
|
||||
|
||||
@@ -102,12 +102,15 @@ limitations under the License.
|
||||
test('cursor scroll behavior', () => {
|
||||
cursorElement._handleDiffRenderStart();
|
||||
assert.equal(cursorElement._scrollBehavior, 'keep-visible');
|
||||
assert.isTrue(cursorElement._focusOnMove);
|
||||
|
||||
cursorElement._handleWindowScroll();
|
||||
assert.equal(cursorElement._scrollBehavior, 'never');
|
||||
assert.isFalse(cursorElement._focusOnMove);
|
||||
|
||||
cursorElement.handleDiffUpdate();
|
||||
assert.equal(cursorElement._scrollBehavior, 'keep-visible');
|
||||
assert.isTrue(cursorElement._focusOnMove);
|
||||
});
|
||||
|
||||
suite('unified diff', () => {
|
||||
|
||||
Reference in New Issue
Block a user