Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

DiegoCardoso
Copy link
Contributor

If a resize or any event that triggers iron-resize happens as the Grid is about to hide, it may lead to some calculations to happen when the Grid is already hidden. That may lead to some misbehavior, like described on the linked issue.

This fix checks the visibility status of the Grid to skip metrics calculation in case the Grid is not visible.

Fixes #2127

Type of change

  • Bugfix
  • Feature

If a resize or any event that triggers `iron-resize` happens as the
Grid is about to hide, it may lead to some calculations to happen
when the Grid is already hidden. That may lead to some misbehavior,
like described on the linked issue.

This fix checks the visibility status of the Grid to skip metrics
calculation in case the Grid is not visible.

fix #2127
@sonarqubecloud
Copy link

Kudos, SonarCloud 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

@web-padawan web-padawan changed the title fix(grid): skip calculation when Grid is hidden fix: skip calculation when grid is hidden Jul 14, 2021
Copy link
Member

@web-padawan web-padawan left a comment

Choose a reason for hiding this comment

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

Should this also be done for master branch or it is not relevant there?

@DiegoCardoso
Copy link
Contributor Author

Should this also be done for master branch or it is not relevant there?

It's not relevant because on master we no longer use iron-list but vaadin-virtual-list instead. I wasn't able to reproduce the same issue when I tested it with the latest grid.

// When this happens, there might be some issues as described
// here https://github.com/vaadin/web-components/issues/2127.
// Skipping any calculation for a hidden Grid.
if (this.hidden) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here, I could also use _isVisible, which does return Boolean(this.offsetWidth || this.offsetHeight). Both works, but _isVisible is used in other places on the class, while hidden is not.

Suggested change
if (this.hidden) {
if (!this._isVisible) {

@DiegoCardoso DiegoCardoso merged commit 7f8ab91 into 20.0 Jul 14, 2021
@DiegoCardoso DiegoCardoso deleted the fix/grid-notify-resize-hidden-grid branch July 14, 2021 13:08
DiegoCardoso added a commit to vaadin/vaadin-grid that referenced this pull request Jul 14, 2021
DiegoCardoso added a commit to vaadin/vaadin-grid that referenced this pull request Jul 14, 2021
DiegoCardoso added a commit to vaadin/vaadin-grid that referenced this pull request Jul 14, 2021
DiegoCardoso added a commit to vaadin/vaadin-grid that referenced this pull request Jul 15, 2021
DiegoCardoso added a commit to vaadin/vaadin-grid that referenced this pull request Jul 15, 2021
DiegoCardoso added a commit that referenced this pull request Aug 2, 2021
This is a complementary fix of #2244.
The original fix works when Grid is directly set to hidden, but fails
for other cases, eg. when a Grid's parent get hidden instead.

This change uses iron-list`s _isVisible to check Grid's visibility
to determine whether any further calculation should be skipped or not.

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

Successfully merging this pull request may close these issues.

2 participants