Fixed an error in containermenu where applying a prefix filter would
leave no item in the entire menu marked as active, causing pressing
enter to throw an error.
Change-Id: Iebdb778629a85cdb77aa7f4a6982dba25484bff5
diff --git a/dev/js/spec/containerMenuSpec.js b/dev/js/spec/containerMenuSpec.js
index 26b2fc3..61f919f 100644
--- a/dev/js/spec/containerMenuSpec.js
+++ b/dev/js/spec/containerMenuSpec.js
@@ -282,6 +282,50 @@
expect(liElements[3]).toBe(undefined);
});
+
+ it('should switch to the containers prefix whenever the prefix filters the regular list to be empty', function () {
+ /**var list = [
+ ["Constituency"],
+ ["Lemma"],
+ ["Morphology"],
+ ["Part-of-Speech"],
+ ["Syntax"]
+ ];
+ */
+ var menu = OwnContainerMenu.create(list,ExampleItemList);
+ menu.container().add("1");
+ menu.show(); // Simulates Buttonpress 1
+ // See function _keypress in containermenu.js (line 147)
+ expect(menu.liveItem()).toBeUndefined(); // no elements in list match "1"
+ expect(menu.container().active()).toBeTruthy(); //thus switch to container
+ var liElements = directElementChildrenByTagName(menu.element(),"li");
+ expect(liElements).toEqual([]);
+ expect(menu.container().liveLength()).toEqual(3); //CI1 and 2, prefix
+ expect(menu._prefix.active()).toBeTruthy(); // HERE ONLY
+ // We want whichever container item was active before
+ // to stay active, default to prefix if none was.
+
+ //simulate _keydown(...) see containermenu.js line 137
+ menu.container().chop();
+ menu.show();
+ menu.prev();
+ expect(menu._prefix.active()).toBeFalsy();
+ expect(menu.container().item(1).active().toBeTruthy); // at location 1: CIItem 2
+ expect(menu.liveLength()).toEqual(5);
+
+ menu.container().add("1");
+ menu.show(); // Simulates Buttonpress 1
+ // See function _keypress in containermenu.js (line 147)
+ expect(menu.liveItem()).toBeUndefined(); // no elements in list match "1"
+ expect(menu.container().active()).toBeTruthy();
+ var liElements = directElementChildrenByTagName(menu.element(),"li");
+ expect(liElements).toEqual([]);
+ expect(menu.container().liveLength()).toEqual(3); //CI1 and 2, prefix
+ expect(menu.container().item(1).active().toBeTruthy); // at location 1: CIItem 2
+ // We want whichever container item was active before
+ // to stay active, default to prefix if none was.
+
+ });
it('should be nextable', function () {
var menu = OwnContainerMenu.create(list);