Skip to content

Commit

Permalink
fixes #33
Browse files Browse the repository at this point in the history
  • Loading branch information
mstahv committed Jun 13, 2024
1 parent 7766724 commit 275f8ff
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/main/java/org/vaadin/tinymce/TinyMce.java
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,12 @@ protected void onAttach(AttachEvent attachEvent) {

@Override
protected void onDetach(DetachEvent detachEvent) {
detachEvent.getUI().getPage().executeJs("""
// See https://github.com/parttio/tinymce-for-flow/issues/33
if(isVisible()) {
detachEvent.getUI().getPage().executeJs("""
tinymce.get($0).remove();
""", id);
}
super.onDetach(detachEvent);
initialContentSent = false;
// save the current value to the dom element in case the component gets
Expand Down
17 changes: 17 additions & 0 deletions src/test/java/org/vaadin/tinymce/DetachInvisible.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.vaadin.tinymce;

import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
import com.vaadin.flow.router.Route;

@Route
public class DetachInvisible extends VerticalLayout {

public DetachInvisible() {
// https://github.com/parttio/tinymce-for-flow/issues/33
TinyMce tinyMce = new TinyMce();
add(tinyMce);
add(new Button("Toggle visible", e-> tinyMce.setVisible(!tinyMce.isVisible())));
add(new Button("Detach", e-> tinyMce.removeFromParent()));
}
}

0 comments on commit 275f8ff

Please sign in to comment.