From 9c24c1d5997ede2b839a99ceea42708bdbfd3b19 Mon Sep 17 00:00:00 2001 From: Serhii Kulykov Date: Thu, 21 Mar 2024 12:50:26 +0200 Subject: [PATCH] fix: fire change event on hyperlink edit, update test timings (#7250) --- .../rich-text-editor/src/vaadin-rich-text-editor-mixin.js | 5 +++-- packages/rich-text-editor/test/basic.common.js | 6 ++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/rich-text-editor/src/vaadin-rich-text-editor-mixin.js b/packages/rich-text-editor/src/vaadin-rich-text-editor-mixin.js index abbabcde08..0f2c5dc7c0 100644 --- a/packages/rich-text-editor/src/vaadin-rich-text-editor-mixin.js +++ b/packages/rich-text-editor/src/vaadin-rich-text-editor-mixin.js @@ -345,8 +345,9 @@ export const RichTextEditorMixin = (superClass) => }); editorContent.addEventListener('focus', () => { - // Format changed, but no value changed happened - if (this._toolbarState === STATE.CLICKED) { + // When editing link, editor gets focus while dialog is still open. + // Keep toolbar state as clicked in this case to fire change event. + if (this._toolbarState === STATE.CLICKED && !this._linkEditing) { this._cleanToolbarState(); } }); diff --git a/packages/rich-text-editor/test/basic.common.js b/packages/rich-text-editor/test/basic.common.js index 3102240347..cc76b36878 100644 --- a/packages/rich-text-editor/test/basic.common.js +++ b/packages/rich-text-editor/test/basic.common.js @@ -448,7 +448,7 @@ describe('rich text editor', () => { editor.focus(); editor.setSelection(0, 6); btn.click(); - await nextUpdate(rte); + await nextRender(); rte.$.linkUrl.value = url; @@ -456,6 +456,7 @@ describe('rich text editor', () => { rte.addEventListener('change', spy); rte.$.confirmLink.click(); + await nextRender(); flushValueDebouncer(); expect(spy.calledOnce).to.be.true; @@ -468,12 +469,13 @@ describe('rich text editor', () => { editor.focus(); editor.setSelection(0, 6); btn.click(); - await nextUpdate(rte); + await nextRender(); const spy = sinon.spy(); rte.addEventListener('change', spy); rte.$.cancelLink.click(); + await nextRender(); flushValueDebouncer(); expect(rte.value).to.equal(value); expect(spy.called).to.be.false;