Skip to content

fix: prevent client updates when handling events from client#6982

Merged
sissbruecker merged 3 commits into
mainfrom
fix/dashboard-no-client-update-on-client-event
Dec 31, 2024
Merged

fix: prevent client updates when handling events from client#6982
sissbruecker merged 3 commits into
mainfrom
fix/dashboard-no-client-update-on-client-event

Conversation

@sissbruecker

Copy link
Copy Markdown
Contributor

When synchronizing state changes from the client to the server (moving items, resizing items, removing items), the dashboard component currently schedules a client update that overrides whatever state currently exists in the client. That means that any client-side changes that have been made during a server-roundtrip can temporarily be reverted and would only be restored after the following server roundtrip.

Assuming that both the WC and the Flow component handle an update in the same way, there is no need to synchronize the server state back to the client when handling an update from the client. To do so, this change prevents executing updateClient when handling updates from the client.

Fixes #6962

Comment on lines +731 to +734
withoutClientUpdate(() -> {
resizedWidget.setColspan(colspan);
resizedWidget.setRowspan(rowspan);
});

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Changing these implicitly triggers a client update.

int nodeId = (int) e.getEventData().getNumber(idKey);
Component removedItem = getItem(nodeId);
removedItem.removeFromParent();
withoutClientUpdate(removedItem::removeFromParent);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Detaching an item implicitly triggers a client update.

}

@Test
public void moveWidget_noClientUpdate() {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The test names are somewhat confusing currently, all of them refer to the case of handling a client event, not doing programmatic updates.

@vursen vursen self-requested a review December 23, 2024 08:55
@sonarqubecloud

Copy link
Copy Markdown

@sissbruecker sissbruecker merged commit 77bff59 into main Dec 31, 2024
@sissbruecker sissbruecker deleted the fix/dashboard-no-client-update-on-client-event branch December 31, 2024 07:50
vaadin-bot pushed a commit that referenced this pull request Dec 31, 2024
* fix: prevent client updates when handling events from client

* address sonar issue
sissbruecker added a commit that referenced this pull request Dec 31, 2024
…6992)

* fix: prevent client updates when handling events from client

* address sonar issue

Co-authored-by: Sascha Ißbrücker <sissbruecker@vaadin.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dashboard overrides client-side state

3 participants