Skip to content

Commit 17d75db

Browse files
authored
HtmlEditor: click on variable toolbar format button before popup is hidden after variable select should not add a undefined variable (T1278577)
1 parent 47e3617 commit 17d75db

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

packages/devextreme/js/__internal/ui/html_editor/modules/m_popup.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ if (Quill) {
113113
}
114114

115115
selectionChangedHandler(e) {
116-
if (this._popup.option('visible')) {
116+
if (this._popup.option('visible') && e.addedItems.length) {
117117
this._popup.hide();
118118

119119
this.insertEmbedContent(e);

packages/devextreme/testing/tests/DevExpress.ui.widgets.htmlEditor/htmlEditorParts/toolbarIntegration.tests.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ const INPUT_CLASS = 'dx-texteditor-input';
2020
const DIALOG_CLASS = 'dx-formdialog';
2121
const DIALOG_FORM_CLASS = 'dx-formdialog-form';
2222
const BUTTON_CLASS = 'dx-button';
23+
const SUGGESTION_LIST_CLASS = 'dx-suggestion-list';
2324
const LIST_ITEM_CLASS = 'dx-list-item';
2425

2526
const BLACK_PIXEL = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVQYGWNgYmL6DwABFgEGpP/tHAAAAABJRU5ErkJggg==';
@@ -1000,5 +1001,34 @@ export default function() {
10001001
$('.dx-suggestion-list .dx-list-item').trigger('dxclick');
10011002
this.clock.tick(10);
10021003
});
1004+
1005+
test('Click on variable toolbar format button before popup is hidden after variable select should not add a undefined variable (T1278577)', function(assert) {
1006+
fx.off = false;
1007+
const expectedValue = '<p><span class="dx-variable" data-var-start-esc-char="%" data-var-end-esc-char="%" data-var-value="test"><span contenteditable="false">%test%</span></span></p>';
1008+
1009+
const editor = $('#htmlEditor').dxHtmlEditor({
1010+
toolbar: { items: ['variable'] },
1011+
variables: {
1012+
dataSource: ['test'],
1013+
escapeChar: '%'
1014+
},
1015+
}).dxHtmlEditor('instance');
1016+
1017+
$('#htmlEditor')
1018+
.find(`.${TOOLBAR_FORMAT_WIDGET_CLASS}`)
1019+
.trigger('dxclick');
1020+
1021+
$(`.${SUGGESTION_LIST_CLASS} .${LIST_ITEM_CLASS}`).trigger('dxclick');
1022+
1023+
$('#htmlEditor')
1024+
.find(`.${TOOLBAR_FORMAT_WIDGET_CLASS}`)
1025+
.trigger('dxclick');
1026+
1027+
this.clock.tick(10);
1028+
1029+
const value = editor.option('value');
1030+
1031+
assert.strictEqual(prepareEmbedValue(value), expectedValue);
1032+
});
10031033
});
10041034
}

0 commit comments

Comments
 (0)