-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed re-attaching in certain cases & using enabled/readOnly flags at…
… the same time related to #27
- Loading branch information
Showing
2 changed files
with
59 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
src/test/java/org/vaadin/tinymce/PreserveOnRefreshBug27.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package org.vaadin.tinymce; | ||
|
||
import com.vaadin.flow.component.button.Button; | ||
import com.vaadin.flow.component.dialog.Dialog; | ||
import com.vaadin.flow.component.orderedlayout.VerticalLayout; | ||
import com.vaadin.flow.router.PreserveOnRefresh; | ||
import com.vaadin.flow.router.Route; | ||
|
||
@Route | ||
@PreserveOnRefresh | ||
public class PreserveOnRefreshBug27 extends VerticalLayout { | ||
|
||
public PreserveOnRefreshBug27() { | ||
Dialog dialog = new Dialog(); | ||
TinyMce tinyMce = new TinyMce(); | ||
tinyMce.configure("branding", false); | ||
tinyMce.configure("statusbar", false); | ||
tinyMce.setValue("<h2>Hallo Leute,</h2>"); | ||
dialog.add(tinyMce); | ||
dialog.add(new Button("Cancel", e -> dialog.close())); | ||
Button open = new Button("Open", e -> dialog.open()); | ||
Button enable = new Button("Disable"); | ||
enable.addClickListener(e -> { | ||
if ("Disable".equals(enable.getText())) { | ||
tinyMce.setEnabled(false); | ||
enable.setText("Enable"); | ||
} else { | ||
tinyMce.setEnabled(true); | ||
enable.setText("Disable"); | ||
} | ||
}); | ||
Button readOnly = new Button("ReadOnly"); | ||
readOnly.addClickListener(e -> { | ||
if ("ReadOnly".equals(readOnly.getText())) { | ||
tinyMce.setReadOnly(true); | ||
readOnly.setText("Writable"); | ||
} else { | ||
tinyMce.setReadOnly(false); | ||
readOnly.setText("ReadOnly"); | ||
} | ||
}); | ||
add(open, enable, readOnly); | ||
} | ||
} |