Skip to content

Commit

Permalink
Fix an exception in closed dxSelectBox with grouped DataSource and fi…
Browse files Browse the repository at this point in the history
…eldTemplate (T658846) (#4828)
  • Loading branch information
mrjohn0011 authored Jul 27, 2018
1 parent 597a608 commit 39a9396
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
4 changes: 1 addition & 3 deletions js/ui/select_box.js
Original file line number Diff line number Diff line change
Expand Up @@ -436,9 +436,7 @@ var SelectBox = DropDownList.inherit({
},

_items: function() {
var items = this._list
? this.option("items")
: this._dataSource.items();
var items = this._getPlainItems(!this._list && this._dataSource.items());

var availableItems = new dataQuery(items).filter("disabled", "<>", true).toArray();

Expand Down
22 changes: 22 additions & 0 deletions testing/tests/DevExpress.ui.widgets.editors/selectBox.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -3468,6 +3468,28 @@ QUnit.test("upArrow and downArrow on textbox change value after change dataSourc
assert.strictEqual(instance.option("value"), 4, "downArrow");
});

QUnit.test("value should be correctly changed via arrow keys when grouped datasource is used", function(assert) {
var $element = $("#selectBox").dxSelectBox({
dataSource: new DataSource({
store: [{ id: 1, text: "item 1", Category: 1 }, { id: 2, text: "item 2", Category: 2 }],
key: "id",
group: "Category"
}),
valueExpr: "id",
value: 1,
grouped: true,
fieldTemplate: function(data) {
return $("<div>").dxTextBox({ value: data.text });
}
}),
$input = $element.find(toSelector(TEXTEDITOR_INPUT_CLASS)),
keyboard = keyboardMock($input);

keyboard.press("down");
$input = $element.find(toSelector(TEXTEDITOR_INPUT_CLASS));
assert.equal($input.val(), "item 2", "navigation is correct");
});

QUnit.test("disabled item should not be selected via keyboard if the widget is closed", function(assert) {
var $element = $("#selectBox").dxSelectBox({ items: [
{ text: "Item 1" },
Expand Down

0 comments on commit 39a9396

Please sign in to comment.