From e2ecb1dcc62d207ff3b1fd43a73be554774cd31c Mon Sep 17 00:00:00 2001 From: "a.dmitryuk" Date: Tue, 9 Dec 2025 17:57:25 +0700 Subject: [PATCH 1/6] Fix editor disconnected not destroyed --- src/main/ts/component/Editor.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/ts/component/Editor.ts b/src/main/ts/component/Editor.ts index 80759b3..ea64f59 100644 --- a/src/main/ts/component/Editor.ts +++ b/src/main/ts/component/Editor.ts @@ -338,6 +338,9 @@ class TinyMceEditor extends HTMLElement { disconnectedCallback(): void { this._mutationObserver.disconnect(); this._updateForm(); + if (this._editor) { + this._getTinymce().remove(this._editor) + } } get value(): string | null { From d9685a756ea6a70069ba1bfe6dfc85148e0245e7 Mon Sep 17 00:00:00 2001 From: "a.dmitryuk" Date: Tue, 9 Dec 2025 18:06:03 +0700 Subject: [PATCH 2/6] changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 01121d5..8df7953 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Editor initialization failure error handling. #INT-3366 +- Disconnected Editor not destroyed. ## 2.3.1 - 2025-08-11 From cd6f2b411e234b42c92321693abafd422f5b1564 Mon Sep 17 00:00:00 2001 From: "a.dmitryuk" Date: Tue, 9 Dec 2025 18:06:55 +0700 Subject: [PATCH 3/6] eslint --- src/main/ts/component/Editor.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/ts/component/Editor.ts b/src/main/ts/component/Editor.ts index ea64f59..4922e17 100644 --- a/src/main/ts/component/Editor.ts +++ b/src/main/ts/component/Editor.ts @@ -339,7 +339,7 @@ class TinyMceEditor extends HTMLElement { this._mutationObserver.disconnect(); this._updateForm(); if (this._editor) { - this._getTinymce().remove(this._editor) + this._getTinymce().remove(this._editor); } } From c9a911969e65f29dff7a7fa3273ecd83a0d42c05 Mon Sep 17 00:00:00 2001 From: "a.dmitryuk" Date: Tue, 16 Dec 2025 10:11:06 +0700 Subject: [PATCH 4/6] add tests --- src/test/ts/browser/LoadTest.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/test/ts/browser/LoadTest.ts b/src/test/ts/browser/LoadTest.ts index 9c44a5a..7770775 100644 --- a/src/test/ts/browser/LoadTest.ts +++ b/src/test/ts/browser/LoadTest.ts @@ -33,13 +33,18 @@ UnitTest.asynctest('LoadTest', (success, failure) => { }), Step.sync(() => makeTinymceElement({ 'setup': 'customElementTinymceSetup', - 'on-init': 'customElementTinymceInit' + 'on-init': 'customElementTinymceInit', + 'id': 'example_id' }, '

Hello world

')), Waiter.sTryUntilPredicate('Waiting for editor setup', () => seenSetup), Waiter.sTryUntilPredicate('Waiting for editor init', () => seenInit), Step.sync(() => { Assertions.assertHtmlStructure('', '

Hello world

', editorInstance.getContent() as string); + Assertions.assertEq('Global TinyMCE is not set', true, Global.tinymce.get('example_id') !== null); }), - Step.sync(() => removeTinymceElement()) + Step.sync(() => removeTinymceElement()), + Step.sync(() => { + Assertions.assertEq('Global TinyMCE not destroyed', true, Global.tinymce.get('example_id') === null); + }) ], success, failure); }); \ No newline at end of file From 34c8cb9e3a975e7f50013926d631d59a56913e31 Mon Sep 17 00:00:00 2001 From: Alexander Dmitryuk Date: Tue, 16 Dec 2025 10:54:42 +0700 Subject: [PATCH 5/6] Update src/test/ts/browser/LoadTest.ts Co-authored-by: tiny-ben-tran --- src/test/ts/browser/LoadTest.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/ts/browser/LoadTest.ts b/src/test/ts/browser/LoadTest.ts index 7770775..ef89dcf 100644 --- a/src/test/ts/browser/LoadTest.ts +++ b/src/test/ts/browser/LoadTest.ts @@ -40,7 +40,7 @@ UnitTest.asynctest('LoadTest', (success, failure) => { Waiter.sTryUntilPredicate('Waiting for editor init', () => seenInit), Step.sync(() => { Assertions.assertHtmlStructure('', '

Hello world

', editorInstance.getContent() as string); - Assertions.assertEq('Global TinyMCE is not set', true, Global.tinymce.get('example_id') !== null); + Assertions.assertEq('An editor instance is registered', true, Global.tinymce.get('example_id') !== null); }), Step.sync(() => removeTinymceElement()), Step.sync(() => { From 858c7344cb14d7f7a5e9ffba64084e2906500871 Mon Sep 17 00:00:00 2001 From: Alexander Dmitryuk Date: Tue, 16 Dec 2025 10:54:49 +0700 Subject: [PATCH 6/6] Update src/test/ts/browser/LoadTest.ts Co-authored-by: tiny-ben-tran --- src/test/ts/browser/LoadTest.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/ts/browser/LoadTest.ts b/src/test/ts/browser/LoadTest.ts index ef89dcf..2c7d4ff 100644 --- a/src/test/ts/browser/LoadTest.ts +++ b/src/test/ts/browser/LoadTest.ts @@ -44,7 +44,7 @@ UnitTest.asynctest('LoadTest', (success, failure) => { }), Step.sync(() => removeTinymceElement()), Step.sync(() => { - Assertions.assertEq('Global TinyMCE not destroyed', true, Global.tinymce.get('example_id') === null); + Assertions.assertEq('The editor instance is removed', true, Global.tinymce.get('example_id') === null); }) ], success, failure); }); \ No newline at end of file