diff --git a/js/ui/drop_down_button.js b/js/ui/drop_down_button.js index 4dd86d35689f..bb5350b3f722 100644 --- a/js/ui/drop_down_button.js +++ b/js/ui/drop_down_button.js @@ -13,7 +13,7 @@ import { DataSource } from '../data/data_source/data_source'; import ArrayStore from '../data/array_store'; import { Deferred } from '../core/utils/deferred'; import { extend } from '../core/utils/extend'; -import { isPlainObject, isDefined } from '../core/utils/type'; +import { isObject, isPlainObject, isDefined } from '../core/utils/type'; import { ensureDefined, noop } from '../core/utils/common'; import Guid from '../core/guid'; import { getElementWidth, getSizeValue } from './drop_down_editor/utils'; @@ -545,9 +545,9 @@ const DropDownButton = Widget.inherit({ }, _getDisplayValue(item) { - const isPrimitiveItem = !isPlainObject(item); + const isPrimitiveItem = !isObject(item); const displayValue = isPrimitiveItem ? item : this._displayGetter(item); - return !isPlainObject(displayValue) ? String(ensureDefined(displayValue, '')) : ''; + return !isObject(displayValue) ? String(ensureDefined(displayValue, '')) : ''; }, _updateActionButton(selectedItem) { diff --git a/testing/tests/DevExpress.ui.widgets/dropDownButton.tests.js b/testing/tests/DevExpress.ui.widgets/dropDownButton.tests.js index bc1b80dc5fb5..17112fe37b01 100644 --- a/testing/tests/DevExpress.ui.widgets/dropDownButton.tests.js +++ b/testing/tests/DevExpress.ui.widgets/dropDownButton.tests.js @@ -1912,6 +1912,33 @@ QUnit.module('deferred datasource', { assert.strictEqual(this.dropDownButton.option('selectedItem'), null, 'init byKey result is ignored'); }); }); + + QUnit.test('should display correct text for non-plain objects(T1233565)', function(assert) { + class Alignment { + constructor(id, name, icon) { + this.id = id; + this.name = name; + this.icon = icon; + } + } + const alignments = [ + new Alignment(1, 'Left', 'alignleft'), + new Alignment(4, 'Right', 'alignright'), + new Alignment(2, 'Center', 'aligncenter'), + new Alignment(3, 'Justify', 'alignjustify'), + ]; + const instance = new DropDownButton($('#dropDownButton'), { + displayExpr: 'name', + keyExpr: 'id', + selectedItemKey: 1, + useSelectMode: true, + dataSource: alignments, + }); + + const textValue = instance.option('text'); + + assert.strictEqual(textValue, 'Left', 'the selected item text is properly shown'); + }); }); QUnit.module('events', {}, () => {