Skip to content

fix: do not call renderer for disconnected columns - #7389

Merged
web-padawan merged 1 commit into
mainfrom
fix/grid-disconnected-column-renderer
May 7, 2024
Merged

web-padawan merged 1 commit into
mainfrom
fix/grid-disconnected-column-renderer

Conversation

@web-padawan

Copy link
Copy Markdown
Member

Description

Added a check to _updateItem() method and a test to verify that removing the vaadin-grid-tree-column doesn't throw.

This fixes the following problem that was reported internally:

TypeError: Cannot read properties of undefined (reading 'itemHasChildrenPath')
    at GridTreeColumn.__defaultRenderer (http://localhost:8080/VAADIN/@fs/Users/serhii/vaadin/web-components/node_modules/@vaadin/grid/src/vaadin-grid-tree-column-mixin.js?t=1715085767730&v=57315da2:51:56)
    at http://localhost:8080/VAADIN/@fs/Users/serhii/vaadin/web-components/node_modules/@vaadin/grid/src/vaadin-grid-mixin.js?t=1715086641624&v=57315da2:955:26
    at Array.forEach (<anonymous>)
    at iterateChildren (http://localhost:8080/VAADIN/@fs/Users/serhii/vaadin/web-components/node_modules/@vaadin/grid/src/vaadin-grid-helpers.js?v=57315da2:26:27)
    at Grid._updateItem (http://localhost:8080/VAADIN/@fs/Users/serhii/vaadin/web-components/node_modules/@vaadin/grid/src/vaadin-grid-mixin.js?t=1715086641624&v=57315da2:949:7)
    at Grid._getItem (http://localhost:8080/VAADIN/@fs/Users/serhii/vaadin/web-components/node_modules/@vaadin/grid/src/vaadin-grid-data-provider-mixin.js?t=1715086247783&v=57315da2:214:14)
    at Grid._updateScrollerItem (http://localhost:8080/VAADIN/@fs/Users/serhii/vaadin/web-components/node_modules/@vaadin/grid/src/vaadin-grid-mixin.js?t=1715086641624&v=57315da2:837:12)
    at IronListAdapter.__updateElement (http://localhost:8080/VAADIN/@fs/Users/serhii/vaadin/web-components/node_modules/@vaadin/component-base/src/virtualizer-iron-list-adapter.js?v=57315da2:240:12)
    at http://localhost:8080/VAADIN/@fs/Users/serhii/vaadin/web-components/node_modules/@vaadin/component-base/src/virtualizer-iron-list-adapter.js?v=57315da2:173:14
    at Array.forEach (<anonymous>)

Did some debugging and here’s what happens in this case:

  1. The vaadin-grid-tree-column and other columns are detached, disconnectedCallback() is called. At this point, _grid reference is cleared
  2. The dataProvider used by the first Grid is replaced with items array used by second Grid
  3. The _dataProviderChanged observer is called by the vaadin-grid and it calls clearCache()
  4. This method calls __updateVisibleRows() which re-renders grid cells also for detached columns.
  5. Re-rendering is done in the loop inside _updateItem method where we don’t check if column._grid is defined.

Type of change

  • Bugfix

@sonarqubecloud

sonarqubecloud Bot commented May 7, 2024

Copy link
Copy Markdown

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@web-padawan
web-padawan removed the request for review from vursen May 7, 2024 13:23
@web-padawan
web-padawan merged commit 4038b4c into main May 7, 2024
@web-padawan
web-padawan deleted the fix/grid-disconnected-column-renderer branch May 7, 2024 13:24
web-padawan added a commit that referenced this pull request May 7, 2024
Co-authored-by: Serhii Kulykov <iamkulykov@gmail.com>
web-padawan added a commit that referenced this pull request May 7, 2024
Co-authored-by: Serhii Kulykov <iamkulykov@gmail.com>
@vaadin-bot

Copy link
Copy Markdown
Collaborator

This ticket/PR has been released with Vaadin 24.5.0.alpha1 and is also targeting the upcoming stable 24.5.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.

3 participants