Fixed scrolling feature in menus for values equal to limit
diff --git a/dev/js/spec/menuSpec.js b/dev/js/spec/menuSpec.js
index f993d33..e19122a 100644
--- a/dev/js/spec/menuSpec.js
+++ b/dev/js/spec/menuSpec.js
@@ -1327,7 +1327,7 @@
expect(menu.shownItem(2).lcField()).toEqual(' veröffentlichungsdatum');
});
- it('should scroll to a chosen value', function () {
+ it('should scroll to a chosen value (1)', function () {
var menu = KorAP.OwnMenu.create(demolist);
menu.limit(3);
@@ -1348,16 +1348,23 @@
expect(menu.shownItem(1).active()).toBe(false);
expect(menu.shownItem(2).active()).toBe(true);
expect(menu.shownItem(3)).toBe(undefined);
-
});
- xit('should highlight a chosen value');
- xit('should move the viewport to active, if active is not in the viewport');
+ it('should scroll to a chosen value (2)', function () {
+ var menu = KorAP.OwnMenu.create(demolonglist);
+
+ // Choose value 3
+ expect(menu.limit(3).show(3)).toBe(true);
+ expect(menu.shownItem(0).lcField()).toEqual(' länge');
+ expect(menu.shownItem(0).active()).toBe(true);
+ expect(menu.shownItem(1).active()).toBe(false);
+ expect(menu.shownItem(2).active()).toBe(false);
+ expect(menu.shownItem(3)).toBe(undefined);
+ });
+
+ xit('should scroll to a chosen value after prefixing, if the chosen value is live');
});
-
-
-
describe('KorAP.Prefix', function () {
it('should be initializable', function () {
var p = prefixClass.create();
diff --git a/dev/js/src/menu.js b/dev/js/src/menu.js
index 2cd99d6..69107d0 100644
--- a/dev/js/src/menu.js
+++ b/dev/js/src/menu.js
@@ -7,6 +7,7 @@
* TODO: space is not a valid prefix!
* TODO: Show the slider briefly on move (whenever screen is called).
* TODO: Ignore alt+ and strg+ key strokes.
+ * TODO: Should scroll to a chosen value after prefixing, if the chosen value is live
*/
define([
'menu/item',
@@ -409,7 +410,8 @@
active = this.liveLength() - 1;
};
- if (active > this._limit) {
+ // Item is outside the first viewport
+ if (active >= this._limit) {
offset = active;
if (offset > (this.liveLength() - this._limit)) {
offset = this.liveLength() - this._limit;