Open jcgueriaud1 opened 3 years ago
From the other ticket. Here is an example to reproduce:
@Route(value = "Future", layout = MainLayout.class)
@RouteAlias(value = "/Future", layout = MainLayout.class)
public class FutureView extends VerticalLayout {
BaseForm form;
public FutureView() {
this.setSizeFull();
form = new BaseForm();
form.open();
Button btn = new Button("Open form");
btn.addClickListener(e->form.open());
add(btn,form);
}
}
class BaseForm extends Dialog {
Tooltip tooltip;
TextField text;
public BaseForm() {
text= new TextField();
text.setReadOnly(true);
tooltip= new Tooltip();
tooltip.attachToComponent(text);
tooltip.add(new Span("Some"));
add(text,tooltip);
}
}
As a temporary solution, using a script in the BaseForm.java class helped me. if you do not open the form in the constructor, the script will not work :(
text.setId("target");
tooltip.setId("tooltip");
UI.getCurrent().getPage().executeJs("document.getElementById('target').onmouseover = function(){"
+ "document.getElementById('tooltip').removeAttribute('hidden');"
+ "};"
+ "document.getElementById('target').onmouseleave = function(){"
+ "document.getElementById('tooltip').setAttribute('hidden', 'true');"
+ "};"
+ "window.onload = function(){"
+ "document.getElementById('overlay').removeAttribute('opened');"
+ "document.getElementById('overlay').setAttribute('closing', 'true');"
+ "};");
Step to reproduce: In the demo