Skip to content

fix: handle added and removed nodes when refreshing tree nodes - #5340

Merged
sissbruecker merged 6 commits into
mainfrom
fix/treegrid_refresh_item
Aug 9, 2023
Merged

sissbruecker merged 6 commits into
mainfrom
fix/treegrid_refresh_item

Conversation

@sissbruecker

@sissbruecker sissbruecker commented Aug 9, 2023 •

Copy link
Copy Markdown
Member

Description

Refreshing a tree node from the server while using the refresh children option currently leads to the grid not displaying the newly added child nodes. For updates initiated from the server, the current connector logic only handles updating existing child items / rows, but does not properly handle changes to the size of the parent item.

This fixes the connector to update the respective grid sub-cache size and effective grid size if it has changed, which causes grid to render the newly added items.

Fixes #5249
Fixes #1027

Type of change

  • Bugfix

@sonatype-lift

sonatype-lift Bot commented Aug 9, 2023

Copy link
Copy Markdown
Contributor

Sonatype Lift is retiring

Sonatype Lift will be retiring on Sep 12, 2023, with its analysis stopping on Aug 12, 2023. We understand that this news may come as a disappointment, and Sonatype is committed to helping you transition off it seamlessly. If you’d like to retain your data, please export your issues from the web console.
We are extremely grateful and thank you for your support over the years.

📖 Read about the impacts and timeline

@sissbruecker

Copy link
Copy Markdown
Member Author

Also tagged #1027 as fixed. The OP doesn't provide a reproduction, so it's not clear what the original issue was. From testing I can confirm that updating, adding and removing direct children works. Nested hierarchical updates don't seem to work, but the refreshItem API also doesn't promise that.

@sissbruecker
sissbruecker marked this pull request as ready for review August 9, 2023 09:45
btn.addClickListener(event -> {
data.addItems("a", "a/a", "a/b");
grid.getDataProvider().refreshItem("a");
grid.getDataProvider().refreshItem("a", true);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

12% of developers fix this issue

NULL_DEREFERENCE: object returned by grid.getDataProvider() could be null and is dereferenced at line 39.


ℹ️ Expand to see all @sonatype-lift commands

You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.

Command Usage
@sonatype-lift ignore Leave out the above finding from this PR
@sonatype-lift ignoreall Leave out all the existing findings from this PR
@sonatype-lift exclude <file|issue|path|tool> Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file

Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.

@sissbruecker
sissbruecker enabled auto-merge (squash) August 9, 2023 13:45
@sonarqubecloud

sonarqubecloud Bot commented Aug 9, 2023

Copy link
Copy Markdown

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@sissbruecker
sissbruecker merged commit add2faf into main Aug 9, 2023
@sissbruecker
sissbruecker deleted the fix/treegrid_refresh_item branch August 9, 2023 14:01
vaadin-bot pushed a commit that referenced this pull request Aug 9, 2023
* fix: handle added and removed nodes when refreshing tree nodes

* use updated getCacheByKey

* add ITs

* use existing ITs instead

* consistently refresh child items in IT page
btn2.addClickListener(event -> {
data.addItems("a/a", "a/a/a", "a/a/c").addItem("a/a/a", "a/a/a/a");
grid.getDataProvider().refreshItem("a/a");
grid.getDataProvider().refreshItem("a/a", true);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

12% of developers fix this issue

NULL_DEREFERENCE: object returned by grid.getDataProvider() could be null and is dereferenced at line 44.


ℹ️ Expand to see all @sonatype-lift commands

You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.

Command Usage
@sonatype-lift ignore Leave out the above finding from this PR
@sonatype-lift ignoreall Leave out all the existing findings from this PR
@sonatype-lift exclude <file|issue|path|tool> Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file

Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.

sissbruecker added a commit that referenced this pull request Aug 10, 2023
#5342)

* fix: handle added and removed nodes when refreshing tree nodes

* use updated getCacheByKey

* add ITs

* use existing ITs instead

* consistently refresh child items in IT page

Co-authored-by: Sascha Ißbrücker <sissbruecker@vaadin.com>
@vaadin-bot

Copy link
Copy Markdown
Collaborator

This ticket/PR has been released with Vaadin 24.2.0.alpha7 and is also targeting the upcoming stable 24.2.0 version.

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.

Tree Grid loses data after moving item between branches refreshItem(startNode, refreshChildren) does NOT refresh children!

3 participants