Do not check the target height when cursor finds no target
Bug: Issue 5812 Change-Id: Iea4913da51314ec635b3b8381fb549ffbc063092
This commit is contained in:
@@ -157,19 +157,21 @@
|
|||||||
const newIndex = this._getNextindex(delta, opt_condition);
|
const newIndex = this._getNextindex(delta, opt_condition);
|
||||||
|
|
||||||
let newTarget = null;
|
let newTarget = null;
|
||||||
if (newIndex != -1) {
|
if (newIndex !== -1) {
|
||||||
newTarget = this.stops[newIndex];
|
newTarget = this.stops[newIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.index = newIndex;
|
||||||
|
this.target = newTarget;
|
||||||
|
|
||||||
|
if (!this.target) { return; }
|
||||||
|
|
||||||
if (opt_getTargetHeight) {
|
if (opt_getTargetHeight) {
|
||||||
this._targetHeight = opt_getTargetHeight(newTarget);
|
this._targetHeight = opt_getTargetHeight(newTarget);
|
||||||
} else {
|
} else {
|
||||||
this._targetHeight = newTarget.scrollHeight;
|
this._targetHeight = newTarget.scrollHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.index = newIndex;
|
|
||||||
this.target = newTarget;
|
|
||||||
|
|
||||||
if (this.focusOnMove) { this.target.focus(); }
|
if (this.focusOnMove) { this.target.focus(); }
|
||||||
|
|
||||||
this._decorateTarget();
|
this._decorateTarget();
|
||||||
|
|||||||
@@ -143,6 +143,13 @@ limitations under the License.
|
|||||||
assert.isTrue(getTargetHeight.called);
|
assert.isTrue(getTargetHeight.called);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('_moveCursor from -1 does not check height', () => {
|
||||||
|
element.stops = list.querySelectorAll('li');
|
||||||
|
const getTargetHeight = sinon.stub();
|
||||||
|
element._moveCursor(1, () => false, getTargetHeight);
|
||||||
|
assert.isFalse(getTargetHeight.called);
|
||||||
|
});
|
||||||
|
|
||||||
test('opt_noScroll', () => {
|
test('opt_noScroll', () => {
|
||||||
sandbox.stub(element, '_targetIsVisible', () => false);
|
sandbox.stub(element, '_targetIsVisible', () => false);
|
||||||
const scrollStub = sandbox.stub(window, 'scrollTo');
|
const scrollStub = sandbox.stub(window, 'scrollTo');
|
||||||
|
|||||||
Reference in New Issue
Block a user