-
Notifications
You must be signed in to change notification settings - Fork 164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Button in a Dialog with LitTemplate: Button caption gets duplicated when dialog is closed and reopened #10119
Comments
This issue occurs for other components as well. For example, if I use // template:
<label id="myLabel">Hi</label>
// java-side:
@Id("myLabel")
Label myCoolLabel;
// main view:
button.addClickListener(ce -> {
Notification notification = new Notification(testForm);
notification.setDuration(3000);
notification.open();
}); then it shows Thus, this is most probably an issue of template functionality, and not of components per se. |
Reproduced with |
To workaround this problem you may wrap the button text into <vaadin-button id="submitButton" theme="primary"><span id="innerTextSpan">OK</span></vaadin-button> but getting/setting the button text will be then problematic:
|
This is the known bug in notification/dialog : https://github.com/vaadin/vaadin-notification/issues/117 and vaadin/vaadin-notification#97.
In fact the latter is quite similar to As a result some modification happens for the Both So this is the problem in The workaround for this specific issue is quite simple: don't reuse dialog instance, use the new one all the time:
|
The issue is not related to Dialog. Modified the provided snippets by removing the Dialog and the Button from inside the template: @customElement('test-form')
export class TestForm extends LitElement {
render() {
return html` <div id="submitButton">OK</div> `;
}
} Server side template: @Tag("test-form")
@JsModule("./views/test-form.ts")
public class TestForm extends LitTemplate {
@Id("submitButton")
Div submitButton;
} View: public class MainView extends VerticalLayout {
public MainView() {
TestForm testForm = new TestForm();
Button button = new Button("Click");
button.addClickListener(ce -> {
if (testForm.getParent().isPresent()) {
remove(testForm);
} else {
add(testForm);
}
});
add(button);
}
} |
Thanks @tomivirkki , apparently it was my mistake to identify this ticket with the existing Notification ticket (which is a genius bug in Dialog/Notification). Anyway, I will take this and proceed further investigation . |
This issue is as I see it the same as discussed at length in #10112 The difference is that in this case, no "clear all" change is sent before a text change event so the text node is appended instead of the content being overwritten. The difference from the code perspective seems to be that it hits
in |
It's similar indeed but not the same. "Clear all" change event is sent indeed in the first case and not sent in the second case. |
Quite similar to #3771. At the moment I don't see any reasonable way to fix this. It's again caused by the changes in the templates behavior : set the text on the server side which matches the text in the template content. The same can be reproduced by manual I would revert the setting text for the Java template from template content which at least hides the original problem (the original problem has been introduced with |
What if |
I don't see any problems with that. Shortly: |
The fix changes |
* fix: treat "clear all" as permanent initial state fixes #10119
* fix: treat "clear all" as permanent initial state fixes #10119
* fix: treat "clear all" as permanent initial state fixes #10119
* fix: treat "clear all" as permanent initial state fixes #10119
* fix: treat "clear all" as permanent initial state fixes #10119
* fix: treat "clear all" as permanent initial state fixes #10119
* fix: treat "clear all" as permanent initial state fixes #10119
* fix: treat "clear all" as permanent initial state fixes #10119
* fix: treat "clear all" as permanent initial state fixes #10119
* fix: treat "clear all" as permanent initial state fixes #10119
This ticket/PR has been released with platform 19.0.0. For prerelease versions, it will be included in its final version. |
Description of the bug / feature
The caption of Buttons in a Dialog that contains a LitTemplate get duplicated if the dialog is opened more than once (if the Button is mapped server-side with @id).
![vaadin-dialog-okok](https://user-images.githubusercontent.com/15888440/108369962-6e3b2800-71fc-11eb-894b-d3395b1ec664.gif)
Short gif highlighting the issue:
Minimal reproducible example
The code is based on vaadin/skeleton-starter-flow-spring - v18.
Client side template:
Server side template:
View:
Expected behavior
I would expect the caption to stay the same.
Actual behavior
The caption is rendered twice.
Versions
The text was updated successfully, but these errors were encountered: