Skip to content

Commit a0ef913

Browse files
dmitryuka.dmitryuktiny-ben-tran
authored
Fix disconnected editor not destroyed (#73)
* Fix editor disconnected not destroyed * changelog * eslint * add tests * Update src/test/ts/browser/LoadTest.ts Co-authored-by: tiny-ben-tran <[email protected]> * Update src/test/ts/browser/LoadTest.ts Co-authored-by: tiny-ben-tran <[email protected]> --------- Co-authored-by: a.dmitryuk <[email protected]> Co-authored-by: tiny-ben-tran <[email protected]>
1 parent 580369c commit a0ef913

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88

99
### Fixed
1010
- Editor initialization failure error handling. #INT-3366
11+
- Disconnected Editor not destroyed.
1112

1213
## 2.3.1 - 2025-08-11
1314

src/main/ts/component/Editor.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,9 @@ class TinyMceEditor extends HTMLElement {
338338
disconnectedCallback(): void {
339339
this._mutationObserver.disconnect();
340340
this._updateForm();
341+
if (this._editor) {
342+
this._getTinymce().remove(this._editor);
343+
}
341344
}
342345

343346
get value(): string | null {

src/test/ts/browser/LoadTest.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,18 @@ UnitTest.asynctest('LoadTest', (success, failure) => {
3333
}),
3434
Step.sync(() => makeTinymceElement({
3535
'setup': 'customElementTinymceSetup',
36-
'on-init': 'customElementTinymceInit'
36+
'on-init': 'customElementTinymceInit',
37+
'id': 'example_id'
3738
}, '<p>Hello world</p>')),
3839
Waiter.sTryUntilPredicate('Waiting for editor setup', () => seenSetup),
3940
Waiter.sTryUntilPredicate('Waiting for editor init', () => seenInit),
4041
Step.sync(() => {
4142
Assertions.assertHtmlStructure('', '<p>Hello world</p>', editorInstance.getContent() as string);
43+
Assertions.assertEq('An editor instance is registered', true, Global.tinymce.get('example_id') !== null);
4244
}),
43-
Step.sync(() => removeTinymceElement())
45+
Step.sync(() => removeTinymceElement()),
46+
Step.sync(() => {
47+
Assertions.assertEq('The editor instance is removed', true, Global.tinymce.get('example_id') === null);
48+
})
4449
], success, failure);
4550
});

0 commit comments

Comments
 (0)