From e0236186e5951c85c8c6bd7b4ae995288f174b6d Mon Sep 17 00:00:00 2001 From: Georgi Krustev Date: Tue, 19 Jan 2016 18:58:00 +0200 Subject: [PATCH] Widget throws an exception when search in grouped list. Fixes telerik/kendo-ui-core#1374 --- src/kendo.dropdownlist.js | 3 ++- tests/dropdownlist/searching.js | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/kendo.dropdownlist.js b/src/kendo.dropdownlist.js index b3427c08f64..2183395ac1e 100644 --- a/src/kendo.dropdownlist.js +++ b/src/kendo.dropdownlist.js @@ -705,7 +705,7 @@ var __meta__ = { // jshint ignore:line _selectNext: function() { var that = this; - var data = that.dataSource.flatView().toJSON(); + var data = that.dataSource.flatView(); var dataLength = data.length + (that.hasOptionLabel() ? 1 : 0); var isInLoop = sameCharsOnly(that._word, that._last); var startIndex = that.selectedIndex; @@ -719,6 +719,7 @@ var __meta__ = { // jshint ignore:line startIndex = normalizeIndex(startIndex, dataLength); } + data = data.toJSON ? data.toJSON() : data.slice(); data = that._shuffleData(data, startIndex); for (var idx = 0; idx < dataLength; idx++) { diff --git a/tests/dropdownlist/searching.js b/tests/dropdownlist/searching.js index b288636fa4d..b39aa8eec3a 100644 --- a/tests/dropdownlist/searching.js +++ b/tests/dropdownlist/searching.js @@ -607,4 +607,22 @@ dropdownlist.open(); dropdownlist.filterInput.val("or").keydown(); }); + + test("search select first match of grouped list", function() { + var data = [{text: "Foo", value: 1, type: "a"}, {text:"Bar", value:2, type: "b"}, {text:"Baz", value:3, type: "a"}]; + var dropdownlist = new DropDownList(input, { + dataTextField: "text", + dataValueField: "value", + dataSource: { + data: data, + group: { field: "type" } + } + }); + + dropdownlist.wrapper.focus().press("b"); + dropdownlist.wrapper.focus().press("b"); + + ok(dropdownlist.ul.children().eq(2).text(), "Bar"); + ok(dropdownlist.ul.children().eq(2).hasClass("k-state-selected")); + }); })();