Skip to content

Commit

Permalink
fix: fire change event on hyperlink edit, update test timings (#7250) (
Browse files Browse the repository at this point in the history
…#7252)

Co-authored-by: Serhii Kulykov <iamkulykov@gmail.com>
  • Loading branch information
vaadin-bot and web-padawan committed Mar 21, 2024
1 parent 6628afc commit 10a5f4d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Expand Up @@ -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();
}
});
Expand Down
6 changes: 4 additions & 2 deletions packages/rich-text-editor/test/basic.common.js
Expand Up @@ -448,14 +448,15 @@ describe('rich text editor', () => {
editor.focus();
editor.setSelection(0, 6);
btn.click();
await nextUpdate(rte);
await nextRender();

rte.$.linkUrl.value = url;

const spy = sinon.spy();
rte.addEventListener('change', spy);

rte.$.confirmLink.click();
await nextRender();
flushValueDebouncer();

expect(spy.calledOnce).to.be.true;
Expand All @@ -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;
Expand Down

0 comments on commit 10a5f4d

Please sign in to comment.