Skip to content
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

fix: treat "clear all" as permanent initial state #10128

Merged
merged 5 commits into from
Feb 26, 2021

Conversation

denis-anisimov
Copy link
Contributor

fixes #10119

public class TestFormIT extends ChromeBrowserTest {

@Test
public void reattachedTemplateHasItsInitialText() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering by this test name.. please ignore if totally out of scope. just wondering. Does that mean the following:

// already attached to the client
testForm.getDiv().setText("Bar");
// already attached client side is updated to "Bar"

// remove TestForm from client
// reattach TestForm to client

Does TestForm has "Template text" or "Bar" on the client? From the test name I would expect "Template text" but from my "state model understanding" I would think it should be "Bar"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no "Bar" in the this scenario.

The original ticket is about duplicated text.
So "Template text" will be duplicated after reattach.

There is an implicit call setText("Template text").

May be you are right that I should avoid implicit setText and call explicitely setText("foo" and check that this is shown in the result...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks that makes the intention more clear and additionally checks that the state is stored in between attachments and not "overwritten" when reattached.

mshabarov
mshabarov previously approved these changes Feb 25, 2021
Copy link
Contributor

@mshabarov mshabarov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not certain whether we need to update the javadoc for generateChangesFromEmpty().
From a modified implementation point of view, it now adds a clear change even if the values are empty.
But Denis's explanations looks reasonable.

Copy link
Contributor

@mshabarov mshabarov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When that instance is then detached in one round trip and attached again in another round trip, then without this PR it will show the "Hello" text because there will be a new client-side instance that runs firstUpdated again but there won't be any clear event from the server. With this PR, a clear event is sent which leads to an empty element.

Apart from the knowledge on how the state nodes work under the hood, I would say that having empty text after first attach, and, then, having "Hello" text after subsequent attach/reattach, would be confusing and opens a gates for bugs, and, as Denis said, a faulty costumer-side code which relies on that behaviour. On the other hand, having the clear all state constantly looks more reasonable, because this behaviour at least expectable.

I think it should be just mentioned in the release notes.

Yes, and I believe we shouldn't maybe release this fix in the flow 2.5 immediately, but, instead, have some test period in latest flow versions to be sure that this would not cause a new regressions.

@denis-anisimov denis-anisimov merged commit d724e7d into master Feb 26, 2021
@denis-anisimov denis-anisimov deleted the 10119-id-mapping branch February 26, 2021 12:09
vaadin-bot pushed a commit that referenced this pull request Feb 26, 2021
* fix: treat "clear all" as permanent initial state

fixes #10119
vaadin-bot pushed a commit that referenced this pull request Feb 26, 2021
* fix: treat "clear all" as permanent initial state

fixes #10119
vaadin-bot pushed a commit that referenced this pull request Feb 26, 2021
* fix: treat "clear all" as permanent initial state

fixes #10119
vaadin-bot pushed a commit that referenced this pull request Feb 26, 2021
* fix: treat "clear all" as permanent initial state

fixes #10119
vaadin-bot pushed a commit that referenced this pull request Feb 26, 2021
* fix: treat "clear all" as permanent initial state

fixes #10119
vaadin-bot pushed a commit that referenced this pull request Feb 26, 2021
* fix: treat "clear all" as permanent initial state

fixes #10119
vaadin-bot pushed a commit that referenced this pull request Feb 26, 2021
* fix: treat "clear all" as permanent initial state

fixes #10119
mshabarov pushed a commit that referenced this pull request Feb 28, 2021
Fixes #10119

Co-authored-by: Denis <denis@vaadin.com>
vaadin-bot pushed a commit that referenced this pull request Mar 1, 2021
* fix: treat "clear all" as permanent initial state

fixes #10119
vaadin-bot pushed a commit that referenced this pull request Mar 1, 2021
* fix: treat "clear all" as permanent initial state

fixes #10119
denis-anisimov pushed a commit that referenced this pull request Mar 1, 2021
…10138)

fix: treat "clear all" as permanent initial state (#10128)

fixes #10119
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Button in a Dialog with LitTemplate: Button caption gets duplicated when dialog is closed and reopened
6 participants