Skip to content

Commit 06a7415

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 297f768 commit 06a7415

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
@@ -147,7 +147,7 @@ class TagBox<
147147
delete this._preserveFocusedTag;
148148
},
149149
enter(e, options): void {
150-
const isListItemFocused = this._list && this._list.option('focusedElement') !== null;
150+
const isListItemFocused = this._list?.option('focusedElement') !== null && this.option('opened') === true;
151151
const isCustomItem = this.option('acceptCustomValue') && !isListItemFocused;
152152

153153
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)