Skip to content

Commit 14e3d4f

Browse files
authored
TagBox: it should be possible to create a custom item by enter key after navigate in list and close popup (T1270280)
1 parent 17fa613 commit 14e3d4f

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

packages/devextreme/js/__internal/ui/m_tag_box.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ const TagBox = (SelectBox as any).inherit({
9797
delete this._preserveFocusedTag;
9898
},
9999
enter(e, options) {
100-
const isListItemFocused = this._list && this._list.option('focusedElement') !== null;
100+
const isListItemFocused = this._list?.option('focusedElement') !== null && this.option('opened') === true;
101101
const isCustomItem = this.option('acceptCustomValue') && !isListItemFocused;
102102

103103
if (isCustomItem) {

packages/devextreme/testing/tests/DevExpress.ui.widgets.editors/tagBox.tests.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1784,6 +1784,32 @@ QUnit.module('the \'onCustomItemCreating\' option', moduleSetup, () => {
17841784
}
17851785
});
17861786
});
1787+
1788+
QUnit.test('It should be possible to create a custom item by enter key after navigate in list and close popup (T1270280)', function(assert) {
1789+
assert.expect(1);
1790+
1791+
const $tagBox = $('#tagBox').dxTagBox({
1792+
items: ['item1', 'item2', 'item3'],
1793+
onCustomItemCreating(e) {
1794+
e.customItem = e.text;
1795+
1796+
assert.strictEqual(e.text, 'it', 'custom item is creating');
1797+
},
1798+
customItemCreateEvent: '',
1799+
acceptCustomValue: true,
1800+
opened: true,
1801+
searchEnabled: true,
1802+
});
1803+
1804+
const $input = $tagBox.find(`.${TEXTEDITOR_INPUT_CLASS}`);
1805+
const keyboard = keyboardMock($input);
1806+
1807+
keyboard
1808+
.type('it')
1809+
.press('down')
1810+
.press('esc')
1811+
.press('enter');
1812+
});
17871813
});
17881814

17891815
QUnit.module('placeholder', () => {

0 commit comments

Comments
 (0)