Repository navigation
fix: do not throw error when adding a new row while a column is hidden - #2144
Merged
Merged
Conversation
tomivirkki
approved these changes
Mar 11, 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2136.
A hidden column removes all of it cells from the DOM.
vaadin-grid/src/vaadin-grid-column.js
Line 595 in 6221b00
All columns's
_setBodyTemplateOrRenderer()method are called when the_cellsproperty changes (e.g.: a new row is added).vaadin-grid/src/vaadin-grid-column.js
Line 153 in 6221b00
This in turn calls the column's
__setColumnTemplateOrRenderer()method and here, for each cell in the column, the grid's__getRowModel()method is called with the cell's parent (i.e.: thetrelement, obtained withcell.parentElement)vaadin-grid/src/vaadin-grid-column.js
Lines 312 to 318 in 6221b00
However, since the cells of a hidden column were removed from the DOM, their
parentElementisnull, thus throwing an error when trying to access any of its properties in the grid's__getRowModel()method.vaadin-grid/src/vaadin-grid.js
Lines 880 to 889 in 6221b00
Just added an extra check to make sure the
__setColumnTemplateOrRenderer()only gets called from the_setBodyTemplateOrRenderer()method if the column is not hidden i.e.: visible.